Here you can find the source of inputStream2String(InputStream in)
public static String inputStream2String(InputStream in) throws IOException
//package com.java2s; import java.io.IOException; import java.io.InputStream; public class Main { public static String inputStream2String(InputStream in) throws IOException { StringBuffer out = new StringBuffer(); byte[] b = new byte[4096]; for (int n; (n = in.read(b)) != -1;) { out.append(new String(b, 0, n)); }//from www .ja v a2 s . c om return out.toString(); } }