Java by API/java.io/FileFilter
Версия от 17:43, 31 мая 2010; (обсуждение)
implements FileFilter
import java.io.File;
import java.io.FileFilter;
public class Main {
public static void main(String[] args) {
File cwd = new File(System.getProperty("user.dir"));
File[] htmlFiles = cwd.listFiles(new HTMLFileFilter());
for (int i = 0; i < htmlFiles.length; i++) {
System.out.println(htmlFiles[i]);
}
}
}
class HTMLFileFilter implements FileFilter {
public boolean accept(File pathname) {
if (pathname.getName().endsWith(".html"))
return true;
if (pathname.getName().endsWith(".htm"))
return true;
return false;
}
}