public final class RegexFilter
extends java.lang.Object
implements java.io.FilenameFilter
Modifier and Type | Field and Description |
---|---|
static int |
BOTH
code for requesting both files and directories.
|
static int |
DIRS
code for requesting directories only
|
static int |
FILES
Code for requesting files only.
|
Constructor and Description |
---|
RegexFilter(java.lang.String positivePattern,
java.lang.String negativePattern,
int want)
constructor
|
public static final int BOTH
public static final int DIRS
public static final int FILES
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?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 filepublic 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.