Here you can find the source of readInputStream(InputStream stream, Charset cs)
public static String readInputStream(InputStream stream, Charset cs) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.nio.charset.Charset; public class Main { public static String readInputStream(InputStream stream, Charset cs) throws IOException { // No real need to close the BufferedReader/InputStreamReader // as they're only wrapping the stream try (final Reader reader = new BufferedReader(new InputStreamReader(stream, cs))) { final StringBuilder builder = new StringBuilder(); final char[] buffer = new char[8192]; int read; while ((read = reader.read(buffer, 0, buffer.length)) > 0) { builder.append(buffer, 0, read); }//from w ww .j a v a2 s. c o m return builder.toString(); } } }