Java tutorial
//package com.java2s; 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 File copyFileTo(File src, File dst) { FileChannel in = null; FileChannel out = null; FileInputStream inStream = null; FileOutputStream outStream = null; try { inStream = new FileInputStream(src); outStream = new FileOutputStream(dst); in = inStream.getChannel(); out = outStream.getChannel(); in.transferTo(0, in.size(), out); } catch (IOException e) { e.printStackTrace(); return null; } finally { try { if (in != null) { in.close(); } if (out != null) { out.close(); } if (inStream != null) { inStream.close(); } if (outStream != null) { outStream.close(); } } catch (IOException e) { e.printStackTrace(); } } return dst; } }