public class 是否以txt结尾 {
public static void main(String[] args) {
File file = new File("d:\\");
String[] strArray = file.list(new FilenameFilter() {
public boolean accept(File dir, String name) {
File file = new File(dir,name);
boolean flag = dir.isFile();
boolean flag2 = name.endsWith(".txt");
return flag2;
}
});
for(String str : strArray){
System.out.println(str);
}
}
} |
|