Class DefaultFileFilter

  • All Implemented Interfaces:
    FileFilter, FilenameFilter

    public class DefaultFileFilter
    extends FileFilter
    implements FileFilter, FilenameFilter
    A FileFilter implementation using Unix-style wildcards.
    Since:
    2.0
    Author:
    Martin Desruisseaux (IRD)
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultFileFilter​(String pattern)
      Constructs a file filter for the specified pattern.
      DefaultFileFilter​(String pattern, String description)
      Constructs a file filter for the specified pattern and description.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean accept​(File file)
      Tests if a specified file matches the pattern.
      boolean accept​(File directory, String name)
      Tests if a specified file matches the pattern.
      String getDescription()
      Returns the description of this filter.
      • Methods inherited from class Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultFileFilter

        public DefaultFileFilter​(String pattern)
        Constructs a file filter for the specified pattern. The pattern can contains the "*" and "?" wildcards.
        Parameters:
        pattern - The pattern (e.g. "*.png").
      • DefaultFileFilter

        public DefaultFileFilter​(String pattern,
                                 String description)
        Constructs a file filter for the specified pattern and description. The pattern can contains the "*" and "?" wildcards.
        Parameters:
        pattern - The pattern (e.g. "*.png").
        description - The description of this filter, usually for graphical user interfaces.
    • Method Detail

      • getDescription

        public String getDescription()
        Returns the description of this filter. For example: "PNG images".
        Specified by:
        getDescription in class FileFilter
      • accept

        public boolean accept​(File file)
        Tests if a specified file matches the pattern.
        Specified by:
        accept in interface FileFilter
        Specified by:
        accept in class FileFilter
        Parameters:
        file - The file to be tested.
        Returns:
        true if and only if the name matches the pattern.
      • accept

        public boolean accept​(File directory,
                              String name)
        Tests if a specified file matches the pattern.
        Specified by:
        accept in interface FilenameFilter
        Parameters:
        directory - The directory in which the file was found.
        name - The name of the file.
        Returns:
        true if and only if the name matches the pattern.