|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mindprod.filter.RegexFilter
public final class RegexFilter
filter out all but files (or directories) that match a given Regex Pattern.
If you are clever, can do multiple positive and negative wildcards. See http://mindprod/quoter.html for help in creating these Strings. The \\ means treat . Literally, not as the "any" character. You need two, because \ has special meaning in Java string literals. On the command line you need only one \. e.g. jgloss.* is "jgloss\\.[.]*" on the command line "jgloss\.[.]*" e.g. ?gloss.html is ".gloss\\.html" on the command line is ".gloss\.html" e.g. to find a list of files "cat\\.txt|dog\\.txt|rabbit\\.txt" On the command line you would type "cat\.txt|dog\.txt|rabbit\.txt" see http://mindprod.com/jgloss/regex.html
Field Summary | |
---|---|
static int |
BOTH
code for requesting both files and directories. |
static boolean |
DEBUGGING
true if debugging. |
static int |
DIRS
code for requesting directories only |
static int |
FILES
Code for requesting files only. |
Constructor Summary | |
---|---|
RegexFilter(java.lang.String positivePattern,
java.lang.String negativePattern,
int want)
constructor |
Method Summary | |
---|---|
boolean |
accept(java.io.File dir,
java.lang.String name)
Select only files that match the Regex Pattern. |
static void |
main(java.lang.String[] args)
Test Harness |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean DEBUGGING
public static final int BOTH
public static final int DIRS
public static final int FILES
Constructor Detail |
---|
public RegexFilter(java.lang.String positivePattern, java.lang.String negativePattern, int want)
positivePattern
- Regex pattern applied to simple filename describing files you want. Null for all.negativePattern
- Regex pattern applied to simple filename\ describing files you don't want. Null for none.want
- What do you want returned FILES, DIRS or BOTH?Method Detail |
---|
public boolean accept(java.io.File dir, java.lang.String name)
accept
in interface java.io.FilenameFilter
dir
- the directory in which the file was found.name
- the simple name of the file
public static void main(java.lang.String[] args)
args
- parm is a TEST regex pattern positive and negative. It will display all files in the current directory
that match. Note that on the command line \\ should not be doubled in regex patterns. On windows,
enclose parms with blanks in "s. This won't work on all platforms.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |