Filter files by name : FileFilter « File Input Output « Java

Filter files by name



public class Main {
  public static void main(String[] argv) throws Exception {
    File dir = new File("c:\\temp");
    FilenameFilter filter = new FilenameFilter() {
      public boolean accept(File dir, String name) {
        return !name.startsWith(".");
    String[] children = dir.list(filter);



Related examples in the same category

1.Filter by file
2.List files of a certain type
3.Filters files based on the extension (what the filename ends with)
4.Extension Filename Filter
5.A prefix based filename filter
6.File filter: retrieve at most predefined number of files which are older than specified data
7.A suffix based file filter.
8.A filesystem filter.