代码就是这:- /*
- *练习:过滤某个路径下的指定文件 使用FilenameFilter
- *
- **/
- import java.io.*;
-
- class AcceptDemo{
-
- public static void main(String args[]){
-
- File f=new File("d:\\");
- FilenameFilter ff=new FilenameFilter(){
- public boolean accept(File dir,String name){
-
- return name.endsWith(".bmp");
- }
-
- };
- String[] arr=f.list(ff);
- for(String name:arr){
-
- System.out.println(name);
- }
- }
-
-
- }
复制代码 |