package com.heima.filefilter.end;
import java.io.File;
import java.io.File;
import java.io.FileFilter;
public class Demo {
public static void main(String[] args) {
File file = new File("e:\\");
File[] listFiles = file.listFiles(new MyFileFilter());
for (File file2 : listFiles) {
System.out.println(file2);
}
}
}
package com.heima.filefilter.end;
class MyFileFilter implements FileFilter{
@Override
public boolean accept(File pathname) {
System.out.println(pathname+"##########");
return pathname.getName().endsWith("ini");
}
}
文件过滤器FileFilter,过滤后输出的结果? |
|