Here you can find the source of readAll(InputStream stream)
public static String readAll(InputStream stream) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String readAll(InputStream stream) throws Exception { BufferedReader reader = null; try {/*from w w w.j a v a 2 s . c om*/ reader = new BufferedReader(new InputStreamReader(stream)); StringBuilder b = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { b.append(line); } return b.toString(); } finally { if (reader != null) reader.close(); } } }