Java tutorial
import java.io.File; import java.io.FilenameFilter; class ExtensionFilter implements FilenameFilter { String ext; public ExtensionFilter(String ext) { this.ext = "." + ext; } public boolean accept(File dir, String name) { return name.endsWith(ext); } } public class Main { public static void main(String args[]) { String dirname = "/java"; File f1 = new File(dirname); FilenameFilter only = new ExtensionFilter("html"); String s[] = f1.list(only); for (int i = 0; i < s.length; i++) { System.out.println(s[i]); } } }