如下所示:
// 删除文件夹private static void deleteDirectory(File file) {if (file.isFile()) {// 表示该文件不是文件夹file.delete();} else {// 首先得到当前的路径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);}以上这篇Java删除指定文件夹下的所有内容的方法(包括此文件夹) 就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持武林网。