Java tutorial
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { private static void writeToOutFile(File toFile, FileInputStream fosfrom) throws IOException { FileOutputStream fosto = null; fosto = new FileOutputStream(toFile); byte bt[] = new byte[1024]; int c; while ((c = fosfrom.read(bt)) > 0) { fosto.write(bt, 0, c); } fosto.close(); } }