Here you can find the source of copy(final String aSrcPath, final String aDestPath)
public static void copy(final String aSrcPath, final String aDestPath) throws IOException
//package com.java2s; //License from project: Apache 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(final String aSrcPath, final String aDestPath) throws IOException { copy(new File(aSrcPath), new File(aDestPath)); }/*from w w w .ja va2 s .co m*/ public static void copy(final File aSrcFile, final File aDestFile) throws IOException { if (aSrcFile.isDirectory()) { aDestFile.mkdirs(); File[] files = aSrcFile.listFiles(); for (File file : files) { String srcFile = aSrcFile.getAbsolutePath() + "\\" + file.getName(); String destFile = aDestFile.getAbsolutePath() + "\\" + file.getName(); copy(new File(srcFile), new File(destFile)); } } else if (aSrcFile.isFile()) { FileChannel srcChannel = null; FileChannel destChannel = null; try { srcChannel = new FileInputStream(aSrcFile).getChannel(); destChannel = new FileOutputStream(aDestFile).getChannel(); srcChannel.transferTo(0, srcChannel.size(), destChannel); } finally { if (null != srcChannel) { srcChannel.close(); } if (null != destChannel) { destChannel.close(); } } } } }