Package org.apache.commons.vfs2.filter
Class WildcardFileFilter
java.lang.Object
org.apache.commons.vfs2.filter.WildcardFileFilter
- All Implemented Interfaces:
- Serializable,- FileFilter
Filters files using the supplied wildcards.
 
This filter selects files and directories based on one or more wildcards. Testing is case-sensitive by default, but this can be configured.
The wildcard matcher uses the characters '?' and '*' to represent a single or multiple wildcard characters. This is the same as often found on Dos/Unix command lines.
For example, to retrieve and print all Java files that have the expression test in the name in the current directory:
 FileSystemManager fsManager = VFS.getManager();
 FileObject dir = fsManager.toFileObject(new File("."));
 FileObject[] files;
 files = dir.findFiles(new FileFilterSelector(new WildcardFileFilter("*test*.java")));
 for (int i = 0; i < files.length; i++) {
     System.out.println(files[i]);
 }
 - Since:
- 2.4
- Author:
- This code was originally ported from Apache Commons IO File Filter
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionWildcardFileFilter(String... wildcards) Constructs a new case-sensitive wildcard filter for an array of wildcards.WildcardFileFilter(List<String> wildcards) Constructs a new case-sensitive wildcard filter for a list of wildcards.WildcardFileFilter(IOCase caseSensitivity, String... wildcards) Constructs a new wildcard filter for an array of wildcards specifying case-sensitivity.WildcardFileFilter(IOCase caseSensitivity, List<String> wildcards) Constructs a new wildcard filter for a list of wildcards specifying case-sensitivity.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanaccept(FileSelectInfo fileSelectInfo) Checks to see if the file name matches one of the wildcards.toString()Provide a String representation of this file filter.
- 
Constructor Details- 
WildcardFileFilterConstructs a new wildcard filter for a list of wildcards specifying case-sensitivity.- Parameters:
- caseSensitivity- how to handle case sensitivity, null means case-sensitive
- wildcards- the list of wildcards to match, not null
 
- 
WildcardFileFilterConstructs a new wildcard filter for an array of wildcards specifying case-sensitivity.- Parameters:
- caseSensitivity- how to handle case sensitivity, null means case-sensitive
- wildcards- the array of wildcards to match, not null
 
- 
WildcardFileFilterConstructs a new case-sensitive wildcard filter for a list of wildcards.- Parameters:
- wildcards- the list of wildcards to match, not null
 
- 
WildcardFileFilterConstructs a new case-sensitive wildcard filter for an array of wildcards.The array is not cloned, so could be changed after constructing the instance. This would be inadvisable however. - Parameters:
- wildcards- the array of wildcards to match
 
 
- 
- 
Method Details- 
acceptChecks to see if the file name matches one of the wildcards.- Specified by:
- acceptin interface- FileFilter
- Parameters:
- fileSelectInfo- the file to check
- Returns:
- true if the file name matches one of the wildcards
 
- 
toStringProvide a String representation of this file filter.
 
-