Java tutorial
//package com.java2s; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { private static final int IO_BUFFER_SIZE = 4 * 1024; private static void copy(InputStream in, BufferedOutputStream out) throws IOException { byte[] b = new byte[IO_BUFFER_SIZE]; int read; while ((read = in.read(b)) != -1) { out.write(b, 0, read); } } }