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