public static void main(String[] args) {
readAllFile("C:\\Users\\73G9Y\\Desktop\\测试");
}
public static void readAllFile(String filepath) {
File file= new File(filepath);
if(!file.isDirectory()){
if(file.getName().indexOf(".docx") > 0){
System.out.println(file.getName());
}
}else if(file.isDirectory()) {
String[] filelist = file.list();
for (int i = 0; i < filelist.length; i++) {
File readfile = new File(filepath);
if (!readfile.isDirectory()) {
if(file.getName().indexOf(".docx") > 0){
System.out.println(file.getName());
}
System.out.println(file.getName());
} else if (readfile.isDirectory()) {
readAllFile(filepath + "\\" + filelist[i]);//递归
}
}
}
}
java删除指定文件夹及所有子文件夹下所有指定类型文件
最新推荐文章于 2023-04-13 16:09:12 发布