Class FileNameRegexFilter


  • public class FileNameRegexFilter
    extends FileFilter
    Author:
    Jorge Campins
    • Constructor Detail

      • FileNameRegexFilter

        public FileNameRegexFilter​(String description,
                                   String regex)
        Creates a FileNameRegexFilter with the specified description and regular expression. The returned FileNameRegexFilter will accept all directories and any file with a file name matching regex.
        Parameters:
        description - textual description for the filter, may be null
        regex - the accepted file name regular expression
        Throws:
        IllegalArgumentException - if regex is null
        PatternSyntaxException - if regex's syntax is invalid
        See Also:
        accept(java.io.File)
      • FileNameRegexFilter

        public FileNameRegexFilter​(String description,
                                   String regex,
                                   boolean dirs)
        Creates a FileNameRegexFilter with the specified description and regular expression. The returned FileNameRegexFilter will accept all directories and any file with a file name matching regex.
        Parameters:
        description - textual description for the filter, may be null
        regex - the accepted file name regular expression
        dirs - true if directories are to be accepted
        Throws:
        IllegalArgumentException - if regex is null
        PatternSyntaxException - if regex's syntax is invalid
        See Also:
        accept(java.io.File)
    • Method Detail

      • accept

        public boolean accept​(File f)
        Tests the specified file, returning true if it is a directory and directories are to be accepted, or its name matches the regular expression of this FileFilter.
        Specified by:
        accept in class FileFilter
        Parameters:
        f - the File to test
        Returns:
        true if the file is to be accepted, false otherwise
      • getPattern

        public Pattern getPattern()
        Returns:
        the regular expression files are tested against
      • toString

        public String toString()
        Overrides:
        toString in class Object
        Returns:
        a string representation of this FileNameRegexFilter