Delete directories recursively in Java
问题 Is there a way to delete entire directories recursively in Java? In the normal case it is possible to delete an empty directory. However when it comes to deleting entire directories with contents, it is not that simple anymore. How do you delete entire directories with contents in Java? 回答1: You should check out Apache's commons-io. It has a FileUtils class that will do what you want. FileUtils.deleteDirectory(new File("directory")); 回答2: With Java 7, we can finally do this with reliable