Here you can find the source of copyFile(File srcFile, File dstFile)
public static void copyFile(File srcFile, File dstFile) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.File; import java.io.InputStream; import java.io.FileInputStream; import java.io.FileOutputStream; public class Main { public static void copyFile(File srcFile, File dstFile) throws IOException { FileInputStream src = new FileInputStream(srcFile); try {// w ww. j a va2 s . c o m copyFile(src, dstFile); } finally { src.close(); } } public static void copyFile(InputStream src, File dstFile) throws IOException { FileOutputStream dst = new FileOutputStream(dstFile); byte[] bytes = new byte[65536]; int count; try { while ((count = src.read(bytes)) != -1) { dst.write(bytes, 0, count); } dst.flush(); } finally { dst.close(); } } }