### Question:
PathUtils { public static void removeRecursive(final Path path) throws IOException { Files.walkFileTree( path, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException { Files.deleteIfExists(file); return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException { Files.deleteIfExists(dir); return FileVisitResult.CONTINUE; } }); } private  PathUtils(); static HashCode sha256(final Path file); static void syncRecursive(final Path source, final Path target); static void removeRecursive(final Path path);  }### Answer:
@Test public void testRemoveRecursive() throws Exception { final Path root = Files.createDirectory(fs.getPath("/", "root")); final Path unrelated = Files.write(root.resolve("unrelated"), new byte[] {0x0f}); final Path dir = Files.createDirectory(root.resolve("dir")); Files.write(dir.resolve("a"), new byte[] {0x00}); Files.write(dir.resolve("b"), new byte[] {0x01}); Files.createSymbolicLink(dir.resolve("c"), dir.resolve("b")); Files.createSymbolicLink(dir.resolve("d"), unrelated); final Path subdir = Files.createDirectory(dir.resolve("subdir")); Files.write(subdir.resolve("e"), new byte[] {0x00}); Files.write(subdir.resolve("f"), new byte[] {0x01}); PathUtils.removeRecursive(dir); assertThat(Files.notExists(dir), describedAs("directory was deleted", is(true))); assertThat(Files.exists(unrelated), describedAs("unrelated file was kept", is(true))); }