Package org.apache.commons.vfs2.filter
Class RegexFileFilter
java.lang.Object
org.apache.commons.vfs2.filter.RegexFileFilter
- All Implemented Interfaces:
- Serializable,- FileFilter
Filters files using supplied regular expression(s).
 
See java.util.regex.Pattern for regex matching rules.
For example, to retrieve and print all Java files where the name matched the regular expression in the current directory:
 FileSystemManager fsManager = VFS.getManager();
 FileObject dir = fsManager.toFileObject(new File("."));
 FileObject[] files = dir.findFiles(new FileFilterSelector(new RegexFileFilter("ˆ.*[tT]est(-\\d+)?\\.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:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringException message when no pattern is given in the constructor.
- 
Constructor SummaryConstructorsConstructorDescriptionRegexFileFilter(String pattern) Constructs a new regular expression filter.RegexFileFilter(String pattern, int flags) Constructs a new regular expression filter with the specified flags.RegexFileFilter(String pattern, IOCase caseSensitivity) Constructs a new regular expression filter with the specified flags case sensitivity.RegexFileFilter(Pattern pattern) Constructs a new regular expression filter for a compiled regular expression.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanaccept(FileSelectInfo fileSelectInfo) Checks to see if the file name matches one of the regular expressions.
- 
Field Details- 
PATTERN_IS_MISSINGException message when no pattern is given in the constructor.- See Also:
 
 
- 
- 
Constructor Details- 
RegexFileFilterConstructs a new regular expression filter for a compiled regular expression.- Parameters:
- pattern- regular expression to match - Cannot be null
 
- 
RegexFileFilterConstructs a new regular expression filter.- Parameters:
- pattern- regular string expression to match - Cannot be null
 
- 
RegexFileFilterConstructs a new regular expression filter with the specified flags.- Parameters:
- pattern- regular string expression to match
- flags- pattern flags - e.g.- Pattern.CASE_INSENSITIVE
 
- 
RegexFileFilterConstructs a new regular expression filter with the specified flags case sensitivity.- Parameters:
- pattern- regular string expression to match - Cannot be null
- caseSensitivity- how to handle case sensitivity, null means case-sensitive
 
 
- 
- 
Method Details- 
acceptChecks to see if the file name matches one of the regular expressions.- Specified by:
- acceptin interface- FileFilter
- Parameters:
- fileSelectInfo- the File to check
- Returns:
- true if the file matches one of the regular expressions
 
 
-