Java tutorial
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String readStream(InputStream stream) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(stream)); StringBuilder contents = new StringBuilder(); String line; while ((line = in.readLine()) != null) { contents.append(line); } return contents.toString(); } }