Filter files by name : FilenameFilter « File « Java Tutorial






import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;

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);

    
  }
}








11.71.FilenameFilter
11.71.1.Combine FilenameFilter and Pattern match to create a dir command
11.71.2.A prefix based filename filter
11.71.3.Filter files by name
11.71.4.strip Extension name
11.71.5.A filesystem filter.
11.71.6.File filter: retrieve at most predefined number of files which are older than specified data