Here you can find the source of deleteDirectory(File path)
static void deleteDirectory(File path)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; import java.nio.file.FileVisitOption; import java.nio.file.Files; import java.nio.file.Path; import java.util.Comparator; import java.util.stream.Stream; public class Main { static void deleteDirectory(File path) { try (Stream<Path> walk = Files.walk(path.toPath(), FileVisitOption.FOLLOW_LINKS)) { walk.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); } catch (IOException ignored) { }/*from w ww . java 2s . c o m*/ } }