Class FileExtFileFilter

  • All Implemented Interfaces:
    FilenameFilter

    public class FileExtFileFilter
    extends Object
    implements FilenameFilter
    A file name filter that checks the file extension to determine whether the filter matches the file name or not. It can have a single or multiple file extensions in the form: 'gif' or 'xml'.
    • Constructor Summary

      Constructors 
      Constructor Description
      FileExtFileFilter​(String aFileExt)
      Constructor for a FilenameFilter that checks a single file extension against supplied file names, looking for matches.
      FileExtFileFilter​(String... aFileExtList)
      Constructor for a FilenameFilter that checks an array of file extensions against supplied file names, looking for matches.
    • Constructor Detail

      • FileExtFileFilter

        public FileExtFileFilter​(String aFileExt)
        Constructor for a FilenameFilter that checks a single file extension against supplied file names, looking for matches.
        Parameters:
        aFileExt - A file extensions (minus the '.') against which we want to compare
      • FileExtFileFilter

        public FileExtFileFilter​(String... aFileExtList)
        Constructor for a FilenameFilter that checks an array of file extensions against supplied file names, looking for matches.
        Parameters:
        aFileExtList - A list of file extensions (minus the '.') against which we want to compare
    • Method Detail

      • toString

        public String toString()
        Returns a string representation of the filter which includes the file name extensions being used as filters.
        Overrides:
        toString in class Object
        Returns:
        A string representation of the filter which includes the file name extensions being used as filters.
      • accept

        public boolean accept​(File aDir,
                              String aFileName)
        Returns true if the supplied file name and parent directory are a match for this FilenameFilter.
        Specified by:
        accept in interface FilenameFilter
        Parameters:
        aDir - A parent directory for the supplied file name
        aFileName - The file name we want to check against our filter
        Returns:
        True if the filter matches the supplied parent and file name; else, false
      • filters

        public boolean filters​(String aFileExt)
        Returns whether or not the supplied file extension is one that this filter matches.
        Parameters:
        aFileExt - A file extension like: jpg, gif, jp2, txt, xml, etc.
        Returns:
        True if this filter matches files with the supplied extension