Top Description Fields Constructors Methods
com.google.common.io

public final Class PatternFilenameFilter

extends Object
implements FilenameFilter
Class Inheritance
All Implemented Interfaces
java.io.FilenameFilter
Annotations
@J2ktIncompatible
@GwtIncompatible
@ElementTypesAreNonnullByDefault
Imports
com.google.common.annotations.GwtIncompatible, .J2ktIncompatible, com.google.common.base.Preconditions, java.io.File, .FilenameFilter, java.util.regex.Pattern, .PatternSyntaxException

File name filter that only accepts files matching a regular expression. This class is thread-safe and immutable.
Author
Apple Chow
Since
1.0

Field Summary

Modifier and TypeField and Description
private final Pattern

Constructor Summary

AccessConstructor and Description
public
PatternFilenameFilter(String
the pattern string on which to filter file names
patternStr
)

Constructs a pattern file name filter object.

public
PatternFilenameFilter(Pattern
the pattern on which to filter file names
pattern
)

Constructs a pattern file name filter object.

Method Summary

Modifier and TypeMethod and Description
public boolean
accept(File
the directory in which the file was found.
dir
,
String
the name of the file.
fileName
)

Implements java.io.FilenameFilter.accept.

Tests if a specified file should be included in a file list.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

patternback to summary
private final Pattern pattern

Constructor Detail

PatternFilenameFilterback to summary
public PatternFilenameFilter(String patternStr)

Constructs a pattern file name filter object.

Parameters
patternStr:String

the pattern string on which to filter file names

Exceptions
PatternSyntaxException:
if pattern compilation fails (runtime)
PatternFilenameFilterback to summary
public PatternFilenameFilter(Pattern pattern)

Constructs a pattern file name filter object.

Parameters
pattern:Pattern

the pattern on which to filter file names

Method Detail

acceptback to summary
public boolean accept(File dir, String fileName)

Implements java.io.FilenameFilter.accept.

Doc from java.io.FilenameFilter.accept.

Tests if a specified file should be included in a file list.

Parameters
dir:File

the directory in which the file was found.

fileName:String

the name of the file.

Returns:boolean

true if and only if the name should be included in the file list; false otherwise.

Annotations
@Override