public static String convertStreamToString ( InputStream in ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( in ) ) ; StringBuilder stringbuilder = new StringBuilder ( ) ; String line = null ; while ( ( line = reader . readLine ( ) ) != null ) { stringbuilder . append ( line + "\n" ) ; } in . close ( ) ; return stringbuilder . toString ( ) ; }
Convert a stream into a single newline separated string