Here you can find the source of copyFile(String srcFileName, String desFileName)
public static void copyFile(String srcFileName, String desFileName)
//package com.java2s; //License from project: Open Source License import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.FileChannel; public class Main { public static void copyFile(String srcFileName, String desFileName) { try {//from www.java2 s . c om FileChannel srcChannel = new FileInputStream(srcFileName).getChannel(); FileChannel dstChannel = new FileOutputStream(desFileName).getChannel(); dstChannel.transferFrom(srcChannel, 0, srcChannel.size()); srcChannel.close(); dstChannel.close(); } catch (IOException e) { e.printStackTrace(); } } }