Here you can find the source of copyFile(File from, File to)
public static File copyFile(File from, File to) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; import java.nio.channels.FileChannel; public class Main { public static File copyFile(File from, File to) throws IOException { FileChannel inChannel = new FileInputStream(from).getChannel(); FileChannel outChannel = new FileOutputStream(to).getChannel(); try {//from w ww.j ava 2 s . c om inChannel.transferTo(0, inChannel.size(), outChannel); } catch (IOException e) { throw e; } finally { if (inChannel != null) inChannel.close(); if (outChannel != null) outChannel.close(); } return to; } }