Here you can find the source of copyFolder(File src, File dst, FilenameFilter filter)
public static void copyFolder(File src, File dst, FilenameFilter filter) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FilenameFilter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.StandardCopyOption; public class Main { public static void copyFolder(File src, File dst, FilenameFilter filter) throws IOException { if (src.isDirectory()) { if (!dst.exists()) { dst.mkdir();/* w ww. ja va2 s .co m*/ } String files[] = src.list(filter); for (String file : files) { File srcFile = new File(src, file); File destFile = new File(dst, file); copyFolder(srcFile, destFile); } } else { copyFile(src, dst); } } public static void copyFolder(File src, File dst) throws IOException { if (src.isDirectory()) { if (!dst.exists()) { dst.mkdir(); } String files[] = src.list(); for (String file : files) { File srcFile = new File(src, file); File destFile = new File(dst, file); copyFolder(srcFile, destFile); } } else { copyFile(src, dst); } } public static void copyFile(File src, File dst) throws IOException { Files.copy(src.toPath(), dst.toPath(), StandardCopyOption.REPLACE_EXISTING); } }