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