Here you can find the source of deleteDirectory(Path directory)
public static void deleteDirectory(Path directory) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; public class Main { public static void deleteDirectory(Path directory) throws IOException { Files.walkFileTree(directory, new SimpleFileVisitor<Path>() { @Override//from w w w.j a v a 2 s . c o m public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { Files.delete(dir); return FileVisitResult.CONTINUE; } }); } }