Here you can find the source of copy(File src, File dist)
public static boolean copy(File src, File dist)
//package com.java2s; //License from project: Open Source License import java.io.Closeable; 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 boolean copy(File src, File dist) { FileInputStream fis = null; FileChannel in = null;//from w w w . j a v a2 s . com FileOutputStream fos = null; FileChannel out = null; try { fis = new FileInputStream(src); in = fis.getChannel(); fos = new FileOutputStream(dist); out = fos.getChannel(); in.transferTo(0, in.size(), out); return true; } catch (IOException e) { return false; } finally { close(in, fis, out, fos); } } public static void close(Closeable... closeables) { for (Closeable c : closeables) try { c.close(); } catch (IOException e) { /* ignore */ } } }