Java tutorial
//package com.java2s; import java.io.IOException; import java.io.InputStream; public class Main { public static final int BUF = 1024; public static String inputStream2String(InputStream in) throws IOException { StringBuffer buf = new StringBuffer(); if (null != in) { byte[] b = new byte[BUF]; int n; while ((n = in.read()) != -1) { buf.append(new String(b, 0, n)); } } return buf.toString(); } }