Here you can find the source of copy(String fromPath, String toPath)
public static final void copy(String fromPath, String toPath) throws IOException
//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 final void copy(String fromPath, String toPath) throws IOException { File sourceFile = new File(fromPath); FileInputStream input = null; FileOutputStream output = null; FileChannel fcin = null;// ww w. j a v a 2 s .c o m FileChannel fcout = null; input = new FileInputStream(sourceFile); output = new FileOutputStream(toPath); fcin = input.getChannel(); fcout = output.getChannel(); long size = fcin.size(); fcin.transferTo(0, size, fcout); fcout.close(); output.close(); input.close(); } }