Java tutorial
//package com.java2s; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { static void copyData(InputStream from, OutputStream to) throws IOException { byte[] buffer = new byte[1024]; int length; while ((length = from.read(buffer)) > 0) { to.write(buffer, 0, length); } to.flush(); to.close(); from.close(); } }