Here you can find the source of copyFile(String source, String destination)
public static void copyFile(String source, String destination) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; 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 source, String destination) throws IOException { File sourceFile = new File(source); File destinationFile = new File(destination); copyFile(sourceFile, destinationFile); }//from w w w. j a v a2 s.co m public static void copyFile(File source, File destination) throws IOException { FileChannel in = null; FileChannel out = null; try { in = new FileInputStream(source).getChannel(); out = new FileOutputStream(destination).getChannel(); in.transferTo(0, in.size(), out); } finally { if (in != null) { in.close(); } if (out != null) { out.close(); } } } }