Here you can find the source of copyFile(String oldPathFile, String newPathFile)
@SuppressWarnings({ "unused", "resource" }) public static void copyFile(String oldPathFile, String newPathFile)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; public class Main { @SuppressWarnings({ "unused", "resource" }) public static void copyFile(String oldPathFile, String newPathFile) { try {/*from w w w. ja va2 s . c o m*/ int bytesum = 0; int byteread = 0; File oldfile = new File(oldPathFile); if (oldfile.exists()) { InputStream inStream = new FileInputStream(oldPathFile); FileOutputStream fs = new FileOutputStream(newPathFile); byte[] buffer = new byte[1444]; while ((byteread = inStream.read(buffer)) != -1) { bytesum += byteread; fs.write(buffer, 0, byteread); } inStream.close(); } } catch (Exception e) { e.printStackTrace(); } } }