Here you can find the source of inputStreamToString(InputStream is)
public static String inputStreamToString(InputStream is) 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; public class Main { protected static final int STREAM_BUFFER_SIZE = 1024; public static String inputStreamToString(InputStream is) throws IOException { StringBuilder sb = new StringBuilder(); Reader reader = new InputStreamReader(is); char[] buffer = new char[STREAM_BUFFER_SIZE]; int count; while ((count = reader.read(buffer)) > 0) { sb.append(buffer, 0, count); }/* w w w . java 2 s. c o m*/ return sb.toString(); } }