Here you can find the source of inputStreamToString(InputStream inputStream, String charsetName)
public static String inputStreamToString(InputStream inputStream, String charsetName) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String inputStreamToString(InputStream inputStream, String charsetName) throws IOException { StringBuilder builder = new StringBuilder(); InputStreamReader reader = new InputStreamReader(inputStream, charsetName); char[] buffer = new char[4 * 1024]; int length; while ((length = reader.read(buffer)) != -1) { builder.append(buffer, 0, length); }//from w ww . j a v a2 s. com return builder.toString(); } }