查找指定目录下的特定文件 (包括子目录)

List read(List l,File fl){
  File[] fls = fl.list(); //你查下api,印象不深了
  for(int i = 0,sz = fls.length;i <sz;i++){
    if(fls[i].isDirectory()){
        read(l,fls[i]);
    }else{
      l.add(fls[i]);
     }
  }
}


欢迎转载,但请保留出处,本文章转自[华软网] 原文链接:http://www.huarw.com/program/java/JAVA02/200805/1583330_2.html

 

 

 

 

File dir=new File("e:/test/");
File[] files
= FileUtils.convertFileCollectionToFileArray(FileUtils
                .listFiles(dir,
new IOFileFilter() {
                   
public boolean accept(File file) {
                       
return accept(file, "");
                    }

                   
public boolean accept(File file, String s) {
                       
return file.isDirectory();
                    }
                },
new IOFileFilter() {
                   
public boolean accept(File file, String s) {
                       
return true;
                    }

                   
public boolean accept(File file) {
                       
return true;
                    }
                }));
System.out.println(files.length);

你可能感兴趣的:(查找指定目录下的特定文件 (包括子目录))