Here you can find the source of loadStream(InputStream in, String encoding)
public static String loadStream(InputStream in, String encoding) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String loadStream(InputStream in) throws IOException { return loadStream(in, "UTF-8"); }/*from w w w . j a va 2 s . c o m*/ public static String loadStream(InputStream in, String encoding) throws IOException { if (encoding == null) encoding = "UTF-8"; ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] buf = new byte[1024]; while (true) { int readlen = in.read(buf); if (readlen == -1) break; bos.write(buf, 0, readlen); } return bos.toString(encoding); } }