Here you can find the source of copyFile(String infile, String outfile)
public static void copyFile(String infile, String outfile)
//package com.java2s; import java.io.FileInputStream; import java.io.FileOutputStream; import java.nio.channels.FileChannel; public class Main { public static void copyFile(String infile, String outfile) { try {/*w ww . j a v a2 s .c om*/ FileInputStream fin = new FileInputStream(infile); FileOutputStream fout = new FileOutputStream(outfile); FileChannel fcin = fin.getChannel(); FileChannel fcout = fout.getChannel(); try { fcout.transferFrom(fcin, 0, fcin.size()); } finally { fcout.close(); fout.close(); } } catch (Exception e) { e.printStackTrace(); } } }