Java tutorial
import java.io.File; import java.io.FileFilter; public class MainClass { 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; } }