public static void main(String[] args) {
//方法一
//方法二
File file=new File("D:\\");
String[] list = file.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
// TODO Auto-generated method stub
//System.out.println(dir+"---"+name);
return new File(dir,name).isFile()&&name.endsWith("txt");
}
});
for(String s:list){
System.out.println(s);
}
}
有人给解释一下不 |