递归删除某个路径下 含有某个特征字符串的所有文件

[quote]

public static void main(String[] args) {
//File mvnDir = new File("C:/Users/20770/.m2/repository");
File mvnDir = new File("C:/Users/20770/.m2/repository/");
if(mvnDir.isDirectory()){
checkDir(mvnDir);
}


}

public static void checkDir(File dir){

File list[] = dir.listFiles();

for(File f:list){
if(f.isDirectory()){
System.out.println("find dir = " + f.getName());
checkDir(f);
}else{
if(f.getName().indexOf(".lastUpdated") > -1 ){
System.out.println("delete file = " + f.getName());
f.delete();
}
}

}

}

[/quote]

你可能感兴趣的:(算法)