public static final String parseInputStreamToString(InputStream stream,boolean html) throws IOException {
  try (InputStreamReader inputStreamReader=new InputStreamReader(stream,StandardCharsets.UTF_8);BufferedReader reader=new BufferedReader(inputStreamReader)){
    StringBuilder contentBuilder=new StringBuilder();
    if (html) {
      contentBuilder.append("<html>");
    }
    String line=reader.readLine();
    while (line != null) {
      contentBuilder.append(line);
      if (html) {
        contentBuilder.append("<br/>");
      }
      line=reader.readLine();
    }
    if (html) {
      contentBuilder.append("</html>");
    }
    return contentBuilder.toString();
  }
 }

public static final String parseInputStreamToString ( InputStream stream , boolean html ) throws IOException { try ( InputStreamReader inputStreamReader = new InputStreamReader ( stream , StandardCharsets . UTF_8 ) ; BufferedReader reader = new BufferedReader ( inputStreamReader ) ) { StringBuilder contentBuilder = new StringBuilder ( ) ; if ( html ) { contentBuilder . append ( "<html>" ) ; } String line = reader . readLine ( ) ; while ( line != null ) { contentBuilder . append ( line ) ; if ( html ) { contentBuilder . append ( "<br/>" ) ; } line = reader . readLine ( ) ; } if ( html ) { contentBuilder . append ( "</html>" ) ; } return contentBuilder . toString ( ) ; } }
reads content from the provided input stream .
