Here you can find the source of copyStream(final InputStream inputStream, final OutputStream out)
public static long copyStream(final InputStream inputStream, final OutputStream out) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static long copyStream(final InputStream inputStream, final OutputStream out) throws IOException { return copyStream(inputStream, out, 10240); }/* w w w .j a va 2 s . co m*/ public static long copyStream(final InputStream inputStream, final OutputStream out, final int bufferSize) throws IOException { long total = 0; byte[] buff = new byte[bufferSize]; int count = inputStream.read(buff); while (count > 0) { out.write(buff, 0, count); total += count; count = inputStream.read(buff); } return total; } }