private static String utf8inputStream2String ( final InputStream inputStream ) throws IOException { StringBuilder stringBuilder = new StringBuilder ( ) ; try ( BufferedReader bufferedReader = new BufferedReader ( new InputStreamReader ( inputStream , StandardCharsets . UTF_8 ) ) ) { String line = null ; while ( ( line = bufferedReader . readLine ( ) ) != null ) { stringBuilder . append ( line ) ; stringBuilder . append ( "\n" ) ; // I know, if the original data stream has no ending line feed, this will add one... } } return stringBuilder . toString ( ) ; }
convert InputStream to String