Filter by file : FileFilter « 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");
    FileFilter fileFilter = new FileFilter() {
      public boolean accept(File file) {
        return file.isDirectory();
      }
    };
    File[] files = dir.listFiles(fileFilter);

    
  }
}








11.72.FileFilter
11.72.1.Create custom File filter
11.72.2.List file with file filter
11.72.3.Custom File Filter
11.72.4.Filter by file
11.72.5.This filter accepts Files that are directories
11.72.6.Filters files based on the extension (what the filename ends with)
11.72.7.Inverted File Filter
11.72.8.Files filter that filters files by their suffix (or extension)
11.72.9.Generic File Filter
11.72.10.A suffix based file filter.