Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String readStream(InputStream is) throws IOException { StringBuilder result = new StringBuilder(); BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8")); String line; while ((line = in.readLine()) != null) { result.append(line); result.append('\n'); } in.close(); return result.toString(); } }