private static String readAsString(InputStream stream) throws IOException {
  StringWriter writer=new StringWriter();
  Reader reader=new BufferedReader(new InputStreamReader(stream,"UTF-8"));
  while (true) {
    int c=reader.read();
    if (c < 0) {
      break;
    }
    writer.write(c);
  }
  return writer.toString();
}

private static String readAsString ( InputStream stream ) throws IOException { StringWriter writer = new StringWriter ( ) ; Reader reader = new BufferedReader ( new InputStreamReader ( stream , "UTF-8" ) ) ; while ( true ) { int c = reader . read ( ) ; if ( c < 0 ) { break ; } writer . write ( c ) ; } return writer . toString ( ) ; }
reads an inputstream and converts it to a string .
