|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.pf.file.FileWalker
public class FileWalker
This class provides services to navigate through a file directory and handle files that match a name filter.
| Field Summary | |
|---|---|
static java.lang.String |
PATTERN_SEPARATOR
The character to be used to separate filename patterns (';') as String. |
static char |
PATTERN_SEPARATOR_CHAR
The character to be used to separate filename patterns (';'). |
static java.lang.String |
RECURSIVE_DIR_WILDCARD
The wildcard pattern that indicates a recursive walkthrough in a single string definition (i.e. "**"). |
| Constructor Summary | |
|---|---|
FileWalker(AFileProcessor processor)
Initialize the new instance with a file processor. |
|
FileWalker(FileHandler handler)
Initialize the new instance with a file handler. |
|
FileWalker(FileHandler handler,
char digitWildcard)
Initialize the new instance with a file handler and a wildcard character for digits. |
|
| Method Summary | |
|---|---|
void |
setDigitWildcardChar(char digitWildcard)
Sets the given character as a wildcard character to match digits ('0'-'9') only. |
long |
walkThrough(java.lang.String searchPattern)
Walks through all directories specified by the given pattern and calls the file handler or file processor for each file that matches the file part in the given pattern. |
long |
walkThrough(java.lang.String dir,
java.io.FilenameFilter filter,
boolean recursive)
Walks through the given directory and optionally through all its sub-directories as well. |
long |
walkThrough(java.lang.String dir,
java.lang.String pattern,
boolean recursive)
This method starts in the given directory to search for all files matching the given pattern(s). |
long |
walkThroughDirectories(java.lang.String startDir,
java.io.FilenameFilter filter,
boolean recursive)
Walks through the given start directory and optionally through all its sub-directories as well. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char PATTERN_SEPARATOR_CHAR
public static final java.lang.String PATTERN_SEPARATOR
public static final java.lang.String RECURSIVE_DIR_WILDCARD
| Constructor Detail |
|---|
public FileWalker(AFileProcessor processor)
public FileWalker(FileHandler handler)
public FileWalker(FileHandler handler,
char digitWildcard)
handler - The file handler that gets all found filesdigitWildcard - A character that is used as wildcard for digits in filname patterns| Method Detail |
|---|
public long walkThrough(java.lang.String dir,
java.lang.String pattern,
boolean recursive)
If recursive is true it goes down to each subdirectory and doing
the same there.
For each matching file (non-directory) the defined FileHandler.handle()
is called.
dir - The directory where to startpattern - The file name pattern(s) for filtering out the correct files ( wildcards '*' and '?' )recursive - If set to true, the file selection is going down to all subdirectories
public long walkThrough(java.lang.String searchPattern)
Examples:
"prog/lib\/**\/a*.jar" ==> Starts in directory prog\lib and walks
recursive through all sub-directories to pass all files that match pattern
"a*.jar" to the file handler.
"d:/temp/tmp???.doc" ==> Passes all files that match pattern
"tmp???.doc" to the file handler.
searchPattern - The pattern that specifies the path and files to walk through
public long walkThrough(java.lang.String dir,
java.io.FilenameFilter filter,
boolean recursive)
dir - The directory to start fromfilter - The filter that decides whether or not a file is passed to the FileHandlerrecursive - If true all subdirectories are scanned as well
public long walkThroughDirectories(java.lang.String startDir,
java.io.FilenameFilter filter,
boolean recursive)
startDir - The directory to start fromfilter - The filter that decides whether or not a directory is passed to the FileHandlerrecursive - If true all subdirectories are scanned as wellpublic void setDigitWildcardChar(char digitWildcard)
digitWildcard - The placeholder character for digits
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||