import java.io.*;
/**
* 文件名过滤
* @author Administrator
*
*/
public class FilenameFilter {
public static void main(String[] args){
File dir = new File("c://");
String[] arr =dir.list(new FilenameFilter(){//list这报错
public boolean accept(File dir,String name){
return name.endsWith(".java");
}
});
for(String name:arr){
System.out.println(name);
}
}
}
|
|