Filter by file : FileFilter « File Input Output « Java






Filter by file

   

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

    
  }
}

   
    
    
  








Related examples in the same category

1.Filter files by name
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.