Package info.freelibrary.util
Class FileExtFileFilter
- java.lang.Object
-
- info.freelibrary.util.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 aFilenameFilter
that checks a single file extension against supplied file names, looking for matches.FileExtFileFilter(String... aFileExtList)
Constructor for aFilenameFilter
that checks an array of file extensions against supplied file names, looking for matches.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(File aDir, String aFileName)
Returns true if the supplied file name and parent directory are a match for thisFilenameFilter
.boolean
filters(String aFileExt)
Returns whether or not the supplied file extension is one that this filter matches.String
toString()
Returns a string representation of the filter which includes the file name extensions being used as filters.
-
-
-
Constructor Detail
-
FileExtFileFilter
public FileExtFileFilter(String aFileExt)
Constructor for aFilenameFilter
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 aFilenameFilter
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.
-
accept
public boolean accept(File aDir, String aFileName)
Returns true if the supplied file name and parent directory are a match for thisFilenameFilter
.- Specified by:
accept
in interfaceFilenameFilter
- Parameters:
aDir
- A parent directory for the supplied file nameaFileName
- 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
-
-