Here you can find the source of copyFile(File orig, File dest)
public static void copyFile(File orig, File dest) throws IOException
//package com.java2s; //License from project: Open Source License 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 orig, File dest) throws IOException { FileInputStream fis = new FileInputStream(orig); FileOutputStream fos = new FileOutputStream(dest); copyData(fis, fos);//from w w w. j a v a 2s . c o m } public static void copyData(InputStream fis, OutputStream fos) throws IOException { try { byte[] buff = new byte[50000]; int readed = -1; while ((readed = fis.read(buff)) > 0) { fos.write(buff, 0, readed); } } finally { fis.close(); fos.close(); } } }