Here you can find the source of deleteDirectoryRecursively(Path path)
public static void deleteDirectoryRecursively(Path path) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; public class Main { public static void deleteDirectoryRecursively(Path path) throws IOException { Files.walkFileTree(path, new FileVisitor<Path>() { @Override//from w w w. ja va 2 s . co m public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { Files.delete(dir); return FileVisitResult.CONTINUE; } @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException { return FileVisitResult.CONTINUE; } }); } }