Java tutorial
//package com.java2s; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static void copyStream(InputStream is, OutputStream os, byte[] buffer) throws IOException { while (true) { int count = is.read(buffer); if (count != -1) { os.write(buffer, 0, count); } else { return; } } } }