RT
我自己写了个 感觉效果不好啊 !!大家最好给我个有效的代码让我参考一下
package untitled6;
import java.io.*;
public class FileExtensionFilter implements FilenameFilter {
private String extension=null;
public FileExtensionFilter(String extension) {
this.extension="."+extension.toLowerCase();
}
public boolean accept(File dir,String name){
File tmp=new File(dir,name);
if(tmp.getName().toLowerCase().endsWith(extension)){
return true;
}
return false;
}
public static void main(String[] args) {
File currentDirectory=new File(".");
FileExtensionFilter ffile= new FileExtensionFilter("f");
String[] ffiles=currentDirectory.list(ffile);
for(int i=0;i<ffiles.length;i++){
System.out.println(ffiles[i]);
}
}
}