Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.InputStream; import java.io.OutputStream; public class Main { public static void copy(InputStream in, OutputStream out) throws Exception { byte[] bucket = new byte[8 * 1024]; int bytesRead = 0; while ((bytesRead = in.read(bucket)) != -1) { out.write(bucket, 0, bytesRead); } } }