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