Java tutorial
//package com.java2s; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String readInputStream(InputStream inputStream) throws IOException { InputStreamReader inputStreamReader = null; try { inputStreamReader = new InputStreamReader(inputStream, "UTF-8"); char[] buffer = new char[512]; StringBuilder str = new StringBuilder(); int i = 0; while ((i = inputStreamReader.read(buffer)) != -1) str.append(buffer, 0, i); return str.toString(); } finally { if (inputStreamReader != null) { inputStreamReader.close(); } } } }