Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public final static long copy(InputStream inp, OutputStream out) throws IOException { int nread; byte[] buf = new byte[4096]; long total = 0; while ((nread = inp.read(buf)) > 0) { total += nread; out.write(buf, 0, nread); } return total; } }