Here you can find the source of copyFile(String fromFilePath, String toFilePath)
public static void copyFile(String fromFilePath, String toFilePath) throws Exception
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; public class Main { public static void copyFile(String fromFilePath, String toFilePath) throws Exception { int bytesum = 0; int byteread = 0; File oldfile = new File(fromFilePath); if (oldfile.exists()) { InputStream inStream = new FileInputStream(fromFilePath); FileOutputStream fs = new FileOutputStream(toFilePath); byte[] buffer = new byte[1444]; while ((byteread = inStream.read(buffer)) != -1) { bytesum += byteread;/* w w w . ja va 2 s .co m*/ System.out.println(bytesum); fs.write(buffer, 0, byteread); } inStream.close(); } } }