public static void delAllFile(File path) {
    if (!path.exists() || !path.isDirectory()) { //不是目录
        return ;
    }
    String[] tmpList = path.list();
    if (tmpList != null) {
        for (String aTempList : tmpList) {
            File tmpFile = new File(path, aTempList);
            if (tmpFile.isFile() && tmpFile.getName().endsWith(".txt")) {
                tmpFile.delete();
            } else if (tmpFile.isDirectory()) {
                delAllFile(tmpFile);
            }
        }
    }
}

 

原创文章,欢迎转载,转载请注明出处!

相关文章:

  • 2022-03-10
  • 2021-10-16
  • 2021-06-11
  • 2021-12-15
  • 2022-12-23
  • 2021-09-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-17
  • 2022-12-23
  • 2022-01-10
  • 2022-12-23
  • 2022-01-31
相关资源
相似解决方案