Here you can find the source of copy(File source, File destination)
public static void copy(File source, File 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 copy(File source, File destination) throws IOException { try {// ww w .j a va 2 s.c om FileChannel sourceChannel = new FileInputStream(source.getPath()).getChannel(); FileChannel destinationChannel = new FileOutputStream(destination.getPath()).getChannel(); destinationChannel.transferFrom(sourceChannel, 0, sourceChannel.size()); sourceChannel.close(); destinationChannel.close(); } catch (Exception e) { System.err.println("Couldn't close sources or write"); } } }