Here you can find the source of copyFolders(File sourceFolder, File destFolder)
public static void copyFolders(File sourceFolder, File destFolder) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.channels.FileChannel; public class Main { public static void copyFolders(File sourceFolder, File destFolder) throws IOException { if (!destFolder.exists()) destFolder.mkdirs();/*from ww w . j a va 2 s. com*/ File[] listFiles = sourceFolder.listFiles(); if (listFiles != null) { for (File srcFile : listFiles) { if (srcFile.isDirectory()) copyFolders(srcFile, new File(destFolder, srcFile.getName())); if (srcFile.isFile()) { File destFile = new File(destFolder, srcFile.getName()); destFile.createNewFile(); copyFiles(srcFile, destFile); } } } } public static void copyFiles(File source, File dest) throws IOException { FileChannel fichannel = new FileInputStream(source).getChannel(); FileChannel foChannel = new FileOutputStream(dest).getChannel(); long size = fichannel.size(); fichannel.transferTo(0, size, foChannel); } }