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); } } } }
原创文章,欢迎转载,转载请注明出处!