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