Here you can find the source of readAll(InputStream in, Charset charset)
public static String readAll(InputStream in, Charset charset) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; import java.nio.charset.Charset; public class Main { public static String readAll(InputStream in, Charset charset) throws IOException { StringWriter output = new StringWriter(); byte[] buffer = new byte[4096]; int n;/*from ww w. j a va2 s .co m*/ while (-1 != (n = in.read(buffer))) { output.write(new String(buffer, 0, n, charset)); } return output.toString(); } }