Package com.globalmentor.io
Class FileExtensionFilter
- java.lang.Object
-
- com.globalmentor.io.FileExtensionFilter
-
- All Implemented Interfaces:
java.io.FileFilter
,java.io.FilenameFilter
public class FileExtensionFilter extends java.lang.Object implements java.io.FileFilter, java.io.FilenameFilter
A class that can filter files based upon extension.- Author:
- Garret Wilson
-
-
Constructor Summary
Constructors Constructor Description FileExtensionFilter(java.lang.String... extensions)
Constructor specifying extensions to include.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(java.io.File file)
Tests whether or not the specified abstract pathname should be included in a pathname list.boolean
accept(java.io.File directory, java.lang.String name)
Tests if a specified file should be included in a file list.protected java.util.Set<java.lang.String>
getExtensionSet()
-
-
-
Method Detail
-
getExtensionSet
protected java.util.Set<java.lang.String> getExtensionSet()
- Returns:
- The extensions to include.
-
accept
public boolean accept(java.io.File directory, java.lang.String name)
Tests if a specified file should be included in a file list. This version accepts a file if the extension is included in the extension set.- Specified by:
accept
in interfacejava.io.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 should be included in the file list;false
otherwise.
-
accept
public boolean accept(java.io.File file)
Tests whether or not the specified abstract pathname should be included in a pathname list. This version accepts a file if the extension is included in the extension set.- Specified by:
accept
in interfacejava.io.FileFilter
- Parameters:
file
- The abstract pathname to be tested.- Returns:
true
if and only ifpathname
should be included
-
-