Here you can find the source of fileCopy(File srcFile, File tarFile)
public static void fileCopy(File srcFile, File tarFile) throws Exception
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static void fileCopy(File srcFile, File tarFile) throws Exception { FileInputStream is = null; FileOutputStream os = null; try {/*from www . ja v a 2s . c om*/ is = new FileInputStream(srcFile); os = new FileOutputStream(tarFile); // write the file to the file specified int bytesRead = 0; byte[] buffer = new byte[8192]; while ((bytesRead = is.read(buffer, 0, 8192)) != -1) { os.write(buffer, 0, bytesRead); } } finally { if (is != null) { is.close(); } if (os != null) { os.close(); } } } }