Here you can find the source of copyDirectory(Path source, ArrayList
public static void copyDirectory(Path source, ArrayList<Path> targets) throws IOException
//package com.java2s; //License from project: Open Source License import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.FileVisitOption; import java.nio.file.FileVisitResult; import java.nio.file.attribute.BasicFileAttributes; import static java.nio.file.FileVisitResult.CONTINUE; import java.util.ArrayList; import java.util.EnumSet; import java.nio.file.FileAlreadyExistsException; import java.io.IOException; public class Main { public static void copyDirectory(Path source, ArrayList<Path> targets) throws IOException { for (Path target : targets) { Files.walkFileTree(source, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<Path>() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { Path targetdir = target.resolve(source.relativize(dir)); //System.out.println(targetdir); // ../tmp try { Files.copy(dir, targetdir); } catch (FileAlreadyExistsException e) { if (!Files.isDirectory(targetdir)) { throw e; }/*from ww w. ja v a 2s.co m*/ } return CONTINUE; } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.copy(file, target.resolve(source.relativize(file))); return CONTINUE; } }); } } }