Code example for IOException

0
        // this is maybe this Android bug: http://code.google.com/p/android/issues/detail?id=15554 
        Log.w(TAG, "Bad URI? " + uri);
        throw new IOException(npe);
      } 
      if (responseCode != HttpURLConnection.HTTP_OK) {
        throw new IOException("Bad HTTP response: " + responseCode);
      } 
      Log.i(TAG, "Consuming " + uri);
      return consume(connection, maxChars);
    } finally { 
      connection.disconnect();
    } 
  } 
 
  private static String getEncoding(URLConnection connection) {
    String contentTypeHeader = connection.getHeaderField("Content-Type");
    if (contentTypeHeader != null) {
      int charsetStart = contentTypeHeader.indexOf("charset=");
      if (charsetStart >= 0) {
        return contentTypeHeader.substring(charsetStart + "charset=".length());
Experience pair programming with AI  Get Codota for Java