public class WildcardFileFilter
extends java.lang.Object
implements java.io.FileFilter, java.io.FilenameFilter
FileFilter
and FilenameFilter
interfaces that can match filenames using a Glob pattern.
The pattern can use *, ?, [abc-z] placeholders.
The directory part of matched files is not checked.Constructor and Description |
---|
WildcardFileFilter(java.lang.String pattern)
Creates a new instance of WildcardFileFilter for the given pattern.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(java.io.File pathname) |
boolean |
accept(java.io.File dir,
java.lang.String name) |
static int |
getFilenameGlobPosition(java.lang.String name)
Returns the position of the first glob char in the given filename.
|
boolean |
match(java.lang.String name)
Returns if the specified
name matches this wildcard. |
java.lang.String |
toString() |
public WildcardFileFilter(java.lang.String pattern) throws java.lang.NullPointerException
*, ?, [abc-z]placeholders.
pattern
- the Glob pattern to usejava.lang.NullPointerException
- if the pattern
was nullpublic static int getFilenameGlobPosition(java.lang.String name)
name
- the file name in which to get the glob charname
does not contain any glob charpublic boolean match(java.lang.String name)
name
matches this wildcard.name
- the string to matchpublic boolean accept(java.io.File pathname)
accept
in interface java.io.FileFilter
public boolean accept(java.io.File dir, java.lang.String name)
accept
in interface java.io.FilenameFilter
public java.lang.String toString()
toString
in class java.lang.Object