NIO2
public class NioDemo {
public static void main(String[] args) throws Exception {
Path path = Paths.get("D:\\workspace\\consume\\consume\\d1");
FileVisitor<Path> visitor = new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
Files.delete(dir);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}
};
Files.walkFileTree(path, visitor);
}
}