public static String asString(final InputStream is,Charset charset) throws IOException {
  try (BufferedReader reader=new BufferedReader(new InputStreamReader(is,charset))){
    final String firstLine=reader.readLine();
    if (firstLine == null) {
      return "";
    }
    final StringBuilder builder=new StringBuilder(firstLine);
    for (String line=reader.readLine(); line != null; line=reader.readLine()) {
      builder.append(EOL);
      builder.append(line);
    }
    return builder.toString();
  }
 }

public static String asString ( final InputStream is , Charset charset ) throws IOException { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( is , charset ) ) ) { final String firstLine = reader . readLine ( ) ; if ( firstLine == null ) { return "" ; } final StringBuilder builder = new StringBuilder ( firstLine ) ; for ( String line = reader . readLine ( ) ; line != null ; line = reader . readLine ( ) ) { builder . append ( EOL ) ; builder . append ( line ) ; } return builder . toString ( ) ; } }
reads the provided input stream as a string and then closes the stream .
