日期:2014-05-20 浏览次数:20790 次
public class Filter implements FilenameFilter {
private String suffix;
public Filter(String suffix) {
super();
this.suffix = suffix;
}
@Override
public boolean accept(File dir, String filename) {
// TODO Auto-generated method stub
return filename.endsWith(suffix);
}
}
public class FindFileUtil {
private static String targetPath = "D:\\pro";
public String targetFile(){
File file = new File(targetPath);
File[] filelist = file.listFiles(new Filter(".java"));
for(int i = 0;i<filelist.length;){
return filelist[i].getName();
}
return null;
}
}