Code example for IOException

0
      out.write(body.getBytes());
      out.close();
    } 
 
    if (connection.getResponseCode() != 200) {
      throw new IOException("Bad response: " + connection.getResponseCode() + " " + connection.getResponseMessage());
    } 
 
    return Util.readFully(connection.getInputStream());
  } 
 
  private HttpsURLConnection getConnection(String urlFragment, String method) throws IOException {
    try { 
      SSLContext context = SSLContext.getInstance("TLS");
      context.init(null, trustManagerFactory.getTrustManagers(), null);
 
      URL url = new URL(String.format("https://gcm.textsecure.whispersystems.org%s", urlFragment));
      HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
      connection.setSSLSocketFactory(context.getSocketFactory());
      connection.setRequestMethod(method);
Stop searching for code, let great code find you!  Add Codota to your java IDE