Java tutorial
//package com.java2s; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String inputStream2String(InputStream in, String encoding) throws Exception { StringBuffer out = new StringBuffer(); InputStreamReader inread = new InputStreamReader(in, encoding); char[] b = new char[4096]; for (int n; (n = inread.read(b)) != -1;) { out.append(new String(b, 0, n)); } return out.toString(); } }