Here you can find the source of consume(InputStream stream, Charset encoding)
public static String consume(InputStream stream, Charset encoding) throws IOException
//package com.java2s; //License from project: LGPL 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 consume(InputStream stream, Charset encoding) throws IOException { final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); final Reader in = new InputStreamReader(stream, encoding); int read; do {/*www. j a v a 2 s . c om*/ read = in.read(buffer, 0, buffer.length); if (read > 0) out.append(buffer, 0, read); } while (read >= 0); return out.toString(); } }