Here you can find the source of copyFile(File srcFile, File destFile)
public static void copyFile(File srcFile, File destFile) 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; public class Main { public static void copyFile(File srcFile, File destFile) throws IOException { FileOutputStream fos = null; FileInputStream fis = null; try {//from w ww.j av a2 s . com byte[] tempBuff = new byte[10240]; fis = new FileInputStream(srcFile); fos = new FileOutputStream(destFile); int readCnt; while (true) { readCnt = fis.read(tempBuff, 0, tempBuff.length); if (readCnt < 0) { break; } if (readCnt > 0) { fos.write(tempBuff, 0, readCnt); fos.flush(); } } } finally { try { fos.close(); } catch (Throwable e) { } try { fis.close(); } catch (Throwable e) { } } } }