private String readFully(HttpURLConnection connection) throws IOException {
  String responseBody="";
  if (connection.getContentLength() != 0) {
    try {
      InputStream in=connection.getInputStream();
      if (in != null) {
        responseBody=readStreamData(in);
      }
    }
 catch (    IOException e) {
      InputStream in=connection.getErrorStream();
      if (in != null) {
        responseBody=readStreamData(in);
      }
 else {
        throw e;
      }
    }
  }
  return responseBody;
}

private String readFully ( HttpURLConnection connection ) throws IOException { String responseBody = "" ; if ( connection . getContentLength ( ) != 0 ) { try { InputStream in = connection . getInputStream ( ) ; if ( in != null ) { responseBody = readStreamData ( in ) ; } } catch ( IOException e ) { InputStream in = connection . getErrorStream ( ) ; if ( in != null ) { responseBody = readStreamData ( in ) ; } else { throw e ; } } } return responseBody ; }
fully reads the input stream from the passed http url connection to prevent ( harmless ) server - side exception .
