Here you can find the source of copyStream(OutputStream out, InputStream in, int bufsz)
public static void copyStream(OutputStream out, InputStream in, int bufsz) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { private static final int BUFSZ = 8196; public static void copyStream(OutputStream out, InputStream in, int bufsz) throws IOException { byte[] buf = new byte[bufsz]; int n = 0; while ((n = in.read(buf)) > 0) { out.write(buf, 0, n);/*from ww w .j av a 2s.c om*/ } } public static void copyStream(OutputStream out, InputStream in) throws IOException { copyStream(out, in, BUFSZ); } }