public class FileExtensionFilter extends Object implements FileFilter
String.endsWith(String).
FilenameFilterfileNameFilter(). This class would simply implement both
interfaces if it weren't for the ambiguity that causes between
File#listFiles(FilenameFilter) and File.listFiles(FileFilter).| Constructor and Description |
|---|
FileExtensionFilter(boolean acceptDirectories,
String... extensions)
Create a file filter that accepts files with the specified
extensions, optionally accepting directories.
|
FileExtensionFilter(String... extensions)
Create a file filter that accepts files with the specified
extensions and accepts all directories.
|
FileExtensionFilter(String extension)
Create a file filter that accepts files with the specified
extension and accepts all directories.
|
FileExtensionFilter(String[] extensions,
boolean acceptDirectories)
Deprecated.
Use the variable-length argument version
FileExtensionFilter(boolean,String[]) instead. |
FileExtensionFilter(String extension,
boolean acceptDirectories)
Create a file filter that accepts files with the specified
extension, optionally accepting directories.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(File pathName)
Return
true if the specified file has an
an acceptable suffix as specified in the constructor. |
protected boolean |
accept(String fileName)
Returns
true if the specified file name has
an acceptable suffix as specified in the constructor. |
FilenameFilter |
fileNameFilter()
Return the file name filter corresponding to this extension
filter.
|
@Deprecated public FileExtensionFilter(String[] extensions, boolean acceptDirectories)
FileExtensionFilter(boolean,String[]) instead.extensions - Suffixes of files to accept.acceptDirectories - true if all directories
should be accepted by this filter.public FileExtensionFilter(boolean acceptDirectories,
String... extensions)
extensions - Suffixes of files to accept.acceptDirectories - true if all directories
should be accepted by this filter.public FileExtensionFilter(String extension, boolean acceptDirectories)
extension - Suffix of files to accept.acceptDirectories - true if all directories
should be accepted by this filter.public FileExtensionFilter(String extension)
extension - Suffix of files to accept.public FileExtensionFilter(String... extensions)
extensions - Suffixes of files to accept.protected final boolean accept(String fileName)
true if the specified file name has
an acceptable suffix as specified in the constructor.fileName - Name of file to test for acceptance.true If file name is acceptable.public boolean accept(File pathName)
true if the specified file has an
an acceptable suffix as specified in the constructor.accept in interface FileFilterpathName - File to test for acceptance.true If file's name is acceptable.public FilenameFilter fileNameFilter()
Copyright © 2016 Alias-i, Inc.. All rights reserved.