FileUtil { public static void copyDir(Path source, Path dest) throws IOException { Files.walkFileTree(source, new CopyDirVisitor(source, dest, StandardCopyOption.REPLACE_EXISTING)); } private  FileUtil(); static void removeDir(Path dir); static void copyDir(Path source, Path dest); static Path createDirectory(Path directory); static ByteSource asByteSource(Path path, OpenOption... openOptions);  }
@Test public void testCopyDir() throws IOException { Path initPaths = fsFoo.getPath("/tmp/a/b/c"); Files.createDirectories(initPaths); Path dest = fsFoo.getPath("/dest/a"); Files.createDirectories(dest); Path remoteDest = fsBar.getPath("/dest/a"); Files.createDirectories(remoteDest); Path source = initPaths.getParent().getParent(); FileUtil.copyDir(source, dest); FileUtil.copyDir(source, remoteDest); assertTrue(Files.exists(fsFoo.getPath("/dest/a/b/c"))); assertTrue(Files.exists(fsBar.getPath("/dest/a/b/c"))); }