Here you can find the source of copyFile(String inFile, String outFile)
public static void copyFile(String inFile, String outFile) 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 inFile, String outFile) throws IOException { File in = new File(inFile); File out = new File(outFile); FileChannel inChannel = null; FileChannel outChannel = null; try {//from w w w . j ava 2s . c o m inChannel = new FileInputStream(in).getChannel(); outChannel = new FileOutputStream(out).getChannel(); inChannel.transferTo(0, inChannel.size(), outChannel); } catch (IOException e) { throw e; } finally { if (inChannel != null) inChannel.close(); if (outChannel != null) outChannel.close(); } } }