Java tutorial
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static void copyFile(File src, File desc) throws IOException { InputStream is = null; OutputStream os = null; try { is = new FileInputStream(src); os = new FileOutputStream(desc); copyStream(is, os); } finally { if (is != null) is.close(); if (os != null) os.close(); } } public static void copyStream(InputStream is, OutputStream os) throws IOException { byte buffer[] = new byte[1024]; int len = -1; while ((len = is.read(buffer, 0, 1024)) != -1) { os.write(buffer, 0, len); } } }