Package com.google.common.io
Class PatternFilenameFilter
- java.lang.Object
-
- com.google.common.io.PatternFilenameFilter
-
- All Implemented Interfaces:
FilenameFilter
@Beta @GwtIncompatible public final class PatternFilenameFilter extends Object implements FilenameFilter
File name filter that only accepts files matching a regular expression. This class is thread-safe and immutable.- Since:
- 1.0
- Author:
- Apple Chow
-
-
Constructor Summary
Constructors Constructor Description PatternFilenameFilter(String patternStr)Constructs a pattern file name filter object.PatternFilenameFilter(Pattern pattern)Constructs a pattern file name filter object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(@Nullable File dir, String fileName)Tests if a specified file should be included in a file list.
-
-
-
Constructor Detail
-
PatternFilenameFilter
public PatternFilenameFilter(String patternStr)
Constructs a pattern file name filter object.- Parameters:
patternStr- the pattern string on which to filter file names- Throws:
PatternSyntaxException- if pattern compilation fails (runtime)
-
PatternFilenameFilter
public PatternFilenameFilter(Pattern pattern)
Constructs a pattern file name filter object.- Parameters:
pattern- the pattern on which to filter file names
-
-
Method Detail
-
accept
public boolean accept(@Nullable File dir, String fileName)
Description copied from interface:java.io.FilenameFilterTests if a specified file should be included in a file list.- Specified by:
acceptin interfaceFilenameFilter- Parameters:
dir- the directory in which the file was found.fileName- the name of the file.- Returns:
trueif and only if the name should be included in the file list;falseotherwise.
-
-