public class FileFilterUtils extends Object
| Constructor | Description |
|---|---|
FileFilterUtils() |
FileFilterUtils is not normally instantiated.
|
| Modifier and Type | Method | Description |
|---|---|---|
static IOFileFilter |
directoryFileFilter() |
Returns a filter that checks if the file is a directory.
|
static IOFileFilter |
fileFileFilter() |
Returns a filter that checks if the file is a file (and not a directory).
|
static File[] |
filter(IOFileFilter filter,
File... files) |
Applies an
IOFileFilter to the provided File
objects. |
static File[] |
filter(IOFileFilter filter,
Iterable<File> files) |
Applies an
IOFileFilter to the provided File
objects. |
static List<File> |
filterList(IOFileFilter filter,
File... files) |
Applies an
IOFileFilter to the provided File
objects. |
static List<File> |
filterList(IOFileFilter filter,
Iterable<File> files) |
Applies an
IOFileFilter to the provided File
objects. |
static Set<File> |
filterSet(IOFileFilter filter,
File... files) |
Applies an
IOFileFilter to the provided File
objects. |
static Set<File> |
filterSet(IOFileFilter filter,
Iterable<File> files) |
Applies an
IOFileFilter to the provided File
objects. |
static IOFileFilter |
nameFileFilter(String name) |
Returns a filter that returns true if the filename matches the specified text.
|
static IOFileFilter |
nameFileFilter(String name,
IOCase caseSensitivity) |
Returns a filter that returns true if the filename matches the specified text.
|
static List<IOFileFilter> |
toList(IOFileFilter... filters) |
Create a List of file filters.
|
public FileFilterUtils()
public static File[] filter(IOFileFilter filter, File... files)
Applies an IOFileFilter to the provided File
objects. The resulting array is a subset of the original file list that
matches the provided filter.
The Set returned by this method is not guaranteed to be thread safe.
Set<File> allFiles = ...
Set<File> javaFiles = FileFilterUtils.filterSet(allFiles,
FileFilterUtils.suffixFileFilter(".java"));
filter - the filter to apply to the set of files.files - the array of files to apply the filter to.files that is accepted by the
file filter.IllegalArgumentException - if the filter is null
or files contains a null value.public static File[] filter(IOFileFilter filter, Iterable<File> files)
Applies an IOFileFilter to the provided File
objects. The resulting array is a subset of the original file list that
matches the provided filter.
The Set returned by this method is not guaranteed to be thread safe.
Set<File> allFiles = ...
Set<File> javaFiles = FileFilterUtils.filterSet(allFiles,
FileFilterUtils.suffixFileFilter(".java"));
filter - the filter to apply to the set of files.files - the array of files to apply the filter to.files that is accepted by the
file filter.IllegalArgumentException - if the filter is null
or files contains a null value.public static List<File> filterList(IOFileFilter filter, Iterable<File> files)
Applies an IOFileFilter to the provided File
objects. The resulting list is a subset of the original files that
matches the provided filter.
The List returned by this method is not guaranteed to be thread safe.
List<File> filesAndDirectories = ...
List<File> directories = FileFilterUtils.filterList(filesAndDirectories,
FileFilterUtils.directoryFileFilter());
filter - the filter to apply to each files in the list.files - the collection of files to apply the filter to.files that is accepted by the
file filter.IllegalArgumentException - if the filter is null
or files contains a null value.public static List<File> filterList(IOFileFilter filter, File... files)
Applies an IOFileFilter to the provided File
objects. The resulting list is a subset of the original files that
matches the provided filter.
The List returned by this method is not guaranteed to be thread safe.
List<File> filesAndDirectories = ...
List<File> directories = FileFilterUtils.filterList(filesAndDirectories,
FileFilterUtils.directoryFileFilter());
filter - the filter to apply to each files in the list.files - the collection of files to apply the filter to.files that is accepted by the
file filter.IllegalArgumentException - if the filter is null
or files contains a null value.public static Set<File> filterSet(IOFileFilter filter, File... files)
Applies an IOFileFilter to the provided File
objects. The resulting set is a subset of the original file list that
matches the provided filter.
The Set returned by this method is not guaranteed to be thread safe.
Set<File> allFiles = ...
Set<File> javaFiles = FileFilterUtils.filterSet(allFiles,
FileFilterUtils.suffixFileFilter(".java"));
filter - the filter to apply to the set of files.files - the collection of files to apply the filter to.files that is accepted by the
file filter.IllegalArgumentException - if the filter is null
or files contains a null value.public static Set<File> filterSet(IOFileFilter filter, Iterable<File> files)
Applies an IOFileFilter to the provided File
objects. The resulting set is a subset of the original file list that
matches the provided filter.
The Set returned by this method is not guaranteed to be thread safe.
Set<File> allFiles = ...
Set<File> javaFiles = FileFilterUtils.filterSet(allFiles,
FileFilterUtils.suffixFileFilter(".java"));
filter - the filter to apply to the set of files.files - the collection of files to apply the filter to.files that is accepted by the
file filter.IllegalArgumentException - if the filter is null
or files contains a null value.public static IOFileFilter nameFileFilter(String name)
name - the filenameNameFileFilterpublic static IOFileFilter nameFileFilter(String name, IOCase caseSensitivity)
name - the filenamecaseSensitivity - how to handle case sensitivity, null means case-sensitiveNameFileFilterpublic static IOFileFilter directoryFileFilter()
DirectoryFileFilter.DIRECTORYpublic static IOFileFilter fileFileFilter()
FileFileFilter.FILEpublic static List<IOFileFilter> toList(IOFileFilter... filters)
filters - The file filtersIllegalArgumentException - if the filters are null or contain a
null value.Copyright © 2026 GeneXus S.A.. All rights reserved.