Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static String readStream(InputStream in) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int i; while ((i = in.read()) != -1) { baos.write(i); } return baos.toString(); } }