Here you can find the source of dumpInputStream(InputStream is, PrintStream p)
private static void dumpInputStream(InputStream is, PrintStream p) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; public class Main { private static void dumpInputStream(InputStream is, PrintStream p) throws IOException { char[] chars = new char[1024]; InputStreamReader reader = new InputStreamReader(is); while (reader.ready()) { int l = reader.read(chars); if (l == chars.length) { p.print(chars);// w w w. ja va 2 s . co m continue; } for (int i = 0; i < l; i++) { p.print(chars[i]); } } } }