|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.io.filefilter.AbstractFileFilter
org.xmlhammer.gui.util.WildcardFileFilter
public class WildcardFileFilter
Filters files using supplied wildcard(s).
See org.apache.commons.io.find.FilenameUtils.wildcardMatch() for wildcard matching rules e.g.
File dir = new File(".");
FileFilter fileFilter = new WildcardFilter("*test*.java~*~");
File[] files = dir.listFiles(fileFilter);
for (int i = 0; i < files.length; i++) {
System.out.println(files[i]);
}
| Constructor Summary | |
|---|---|
WildcardFileFilter(java.util.List<java.lang.String> patterns)
Construct a new wildcard filter for a list of wildcards |
|
WildcardFileFilter(java.lang.String pattern)
Construct a new wildcard filter for a single wildcard |
|
WildcardFileFilter(java.lang.String[] pattern)
Construct a new wildcard filter for an array of wildcards |
|
| Method Summary | |
|---|---|
boolean |
accept(java.io.File file)
Checks to see if the filename matches one of the wildcards. |
boolean |
accept(java.io.File dir,
java.lang.String name)
Checks to see if the filename matches one of the wildcards. |
(package private) static java.lang.String[] |
splitOnTokens(java.lang.String text)
|
static boolean |
wildcardMatch(java.lang.String filename,
java.lang.String wildcardMatcher)
Checks a filename to see if it matches the specified wildcard matcher. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WildcardFileFilter(java.lang.String pattern)
wildcard - wildcard to match
java.lang.IllegalArgumentException - if the pattern is nullpublic WildcardFileFilter(java.lang.String[] pattern)
wildcards - wildcards to match
java.lang.IllegalArgumentException - if the pattern array is nullpublic WildcardFileFilter(java.util.List<java.lang.String> patterns)
wildcards - list of wildcards to match
java.lang.IllegalArgumentException - if the pattern list is null
java.lang.ClassCastException - if the list does not contain Strings| Method Detail |
|---|
public boolean accept(java.io.File dir,
java.lang.String name)
accept in interface java.io.FilenameFilteraccept in interface org.apache.commons.io.filefilter.IOFileFilteraccept in class org.apache.commons.io.filefilter.AbstractFileFilterdir - the file directoryname - the filename
public boolean accept(java.io.File file)
accept in interface java.io.FileFilteraccept in interface org.apache.commons.io.filefilter.IOFileFilteraccept in class org.apache.commons.io.filefilter.AbstractFileFilterfile - the file to check
public static boolean wildcardMatch(java.lang.String filename,
java.lang.String wildcardMatcher)
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. The extension check is case sensitive on Unix and case insensitive on Windows.
wildcardMatch("c.txt", "*.txt") --> true
wildcardMatch("c.txt", "*.jpg") --> false
wildcardMatch("a/b/c.txt", "a/b/*") --> true
wildcardMatch("c.txt", "*.???") --> true
wildcardMatch("c.txt", "*.????") --> false
filename - the filename to match onwildcardMatcher - the wildcard string to match against
static java.lang.String[] splitOnTokens(java.lang.String text)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||