Here you can find the source of CopyFile(File srcFile, File destFile)
public static void CopyFile(File srcFile, File destFile)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static void CopyFile(File srcFile, File destFile) { try {/*from w w w . j a va 2s . c om*/ int bytesum = 0; int byteread = 0; InputStream inStream = new FileInputStream(srcFile); FileOutputStream fs = new FileOutputStream(destFile); byte[] buffer = new byte[1444]; while ((byteread = inStream.read(buffer)) != -1) { bytesum += byteread; fs.write(buffer, 0, byteread); } inStream.close(); fs.close(); } catch (Exception e) { e.printStackTrace(); } } public static void CopyFile(String srcFile, String destFile) { try { File src = new File(srcFile); File dest = new File(destFile); if (!dest.exists()) { dest.createNewFile(); CopyFile(src, dest); } } catch (IOException e) { e.printStackTrace(); } } }