Here you can find the source of readAll(InputStream in)
static String readAll(InputStream in) throws Exception
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; public class Main { static String readAll(InputStream in) throws Exception { return readAll(in, new StringBuilder()); }//from w w w. j a v a2s. c om public static String readAll(InputStream in, StringBuilder sb) throws Exception { final BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line; while ((line = reader.readLine()) != null) { sb.append(line); sb.append('\n'); } return sb.toString(); } }