Here you can find the source of readAll(InputStream in)
public static final String readAll(InputStream in) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; public class Main { /**/*from w ww . j a va2 s. c om*/ * Read all bytes available on the input stream, and concatenates them into a string. * N.B. This casts bytes read directly to characters. */ public static final String readAll(InputStream in) throws IOException { StringBuilder bob = new StringBuilder(); int c; while ((c = in.read()) != -1) { bob.append((char) c); } return bob.toString(); } }