Here you can find the source of delete(File toRecurse)
public static void delete(File toRecurse) throws IOException
//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; public class Main { public static void delete(File toRecurse) throws IOException { Files.walk(toRecurse.toPath(), FileVisitOption.FOLLOW_LINKS).sorted(Comparator.reverseOrder()) .map(Path::toFile).forEach(File::delete); }/*w ww . ja va2s .c o m*/ }