Java Code Examples for java.net.ProtocolException#printStackTrace()

The following examples show how to use java.net.ProtocolException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenericHttpClient.java    From SI with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setRequestMethod( String requestMethod ){
    try {
        conn.setRequestMethod(requestMethod);
        conn.setDoOutput(true);
    } catch( ProtocolException pe ) {
       pe.printStackTrace();
    }
}
 
Example 2
Source File: OneM2MHttpClient.java    From SI with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setRequestMethod( String requestMethod ){
    try {
        conn.setRequestMethod(requestMethod);
        conn.setDoOutput(true);
    } catch( ProtocolException pe ) {
       pe.printStackTrace();
    }
}
 
Example 3
Source File: FiwareHttpClient.java    From SI with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setRequestMethod( String requestMethod ){
    try {
        conn.setRequestMethod(requestMethod);
        conn.setDoOutput(true);
    } catch( ProtocolException pe ) {
       pe.printStackTrace();
    }
}
 
Example 4
Source File: GenericHttpClient.java    From SI with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setRequestMethod( String requestMethod ){
    try {
        conn.setRequestMethod(requestMethod);
        conn.setDoOutput(true);
    } catch( ProtocolException pe ) {
       pe.printStackTrace();
    }
}
 
Example 5
Source File: OneM2MHttpClient.java    From SI with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setRequestMethod( String requestMethod ){
    try {
        conn.setRequestMethod(requestMethod);
        conn.setDoOutput(true);
    } catch( ProtocolException pe ) {
       pe.printStackTrace();
    }
}
 
Example 6
Source File: FiwareHttpClient.java    From SI with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setRequestMethod( String requestMethod ){
    try {
        conn.setRequestMethod(requestMethod);
        conn.setDoOutput(true);
    } catch( ProtocolException pe ) {
       pe.printStackTrace();
    }
}
 
Example 7
Source File: MultiThreadFetcher.java    From SEAL with Apache License 2.0 5 votes vote down vote up
private static void setRequestHeader(HttpURLConnection conn) {
  try {
    conn.setRequestMethod(REQUEST_METHOD);
  } catch (ProtocolException e) {
     e.printStackTrace();
  }
  for (int i = 1; i < HTTP_REQUEST.length; i+=2)
    conn.setRequestProperty(HTTP_REQUEST[i-1], HTTP_REQUEST[i]);
}
 
Example 8
Source File: AppbarActivity.java    From letv with Apache License 2.0 4 votes vote down vote up
protected byte[] a(String... strArr) {
    try {
        try {
            HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(strArr[0]).openConnection();
            httpURLConnection.setConnectTimeout(5000);
            try {
                httpURLConnection.setRequestMethod("GET");
                try {
                    InputStream inputStream = httpURLConnection.getInputStream();
                    try {
                        if (httpURLConnection.getResponseCode() == 200) {
                            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                            byte[] bArr = new byte[1024];
                            while (true) {
                                int read = inputStream.read(bArr);
                                if (read != -1) {
                                    byteArrayOutputStream.write(bArr, 0, read);
                                } else {
                                    byteArrayOutputStream.close();
                                    inputStream.close();
                                    return byteArrayOutputStream.toByteArray();
                                }
                            }
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    return null;
                } catch (IOException e2) {
                    e2.printStackTrace();
                    return null;
                }
            } catch (ProtocolException e3) {
                e3.printStackTrace();
                return null;
            }
        } catch (IOException e22) {
            e22.printStackTrace();
            return null;
        }
    } catch (MalformedURLException e4) {
        e4.printStackTrace();
        return null;
    }
}