As shown below:
// Delete the folder private static void deleteDirectory(File file) {if (file.isFile()) {// Indicate that the file is not a folder file.delete();} else {// First get the current path String[] childFilePaths = file.list();for (String childFilePath : childFilePaths) {File childFile = new File(file.getAbsolutePath() + "/" + childFilePath);deleteDirectory(childFile);}file.delete();}}public static void main(String[] args) {File del_file = new File("D:/Test/ibs" + "/temp/");deleteDirectory(del_file);}The above method of deleting all contents in a specified folder (including this folder) in Java is all the content shared by the editor. I hope it can give you a reference and I hope you can support Wulin.com more.