Here you can find the source of copyStream(InputStream in, OutputStream out)
public static void copyStream(InputStream in, OutputStream out) throws IOException
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; public class Main { public static void copyStream(InputStream in, OutputStream out) throws IOException { byte[] buf = new byte[4096]; int len;//from w ww . j a v a 2s .c o m while ((len = in.read(buf)) != -1) { out.write(buf, 0, len); } } public static void copyStream(BufferedReader in, OutputStreamWriter out) throws IOException { char[] buf = new char[4096]; int len; while ((len = in.read(buf)) != -1) { out.write(buf, 0, len); } } }