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 stringFrom(InputStream stream, String encoding) { StringBuilder builder = new StringBuilder(); try { BufferedReader reader = new BufferedReader(new InputStreamReader(stream, encoding)); while (reader.ready()) builder.append(reader.readLine()); reader.close(); } catch (IOException ie) { } return builder.toString(); } }