private String readFully(InputStream input) throws IOException {
  if (input == null) {
    throw new FileNotFoundException();
  }
  final BufferedReader in=new BufferedReader(new InputStreamReader(input,charset));
  try {
    StringBuilder sb=new StringBuilder();
    String line;
    while ((line=in.readLine()) != null) {
      if (sb.length() > 0) {
        sb.append('\n');
      }
      sb.append(line);
    }
    return sb.toString();
  }
  finally {
    in.close();
  }
}

private String readFully ( InputStream input ) throws IOException { if ( input == null ) { throw new FileNotFoundException ( ) ; } final BufferedReader in = new BufferedReader ( new InputStreamReader ( input , charset ) ) ; try { StringBuilder sb = new StringBuilder ( ) ; String line ; while ( ( line = in . readLine ( ) ) != null ) { if ( sb . length ( ) > 0 ) { sb . append ( '\n' ) ; } sb . append ( line ) ; } return sb . toString ( ) ; } finally { in . close ( ) ; } }
basic utility method to fully read a stream into memory . the input stream will be closed afterwards .
