|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectFileWalker
public abstract class FileWalker
The FileWalker
class is a utility class that simplifies
traversing all the files in a file-system directory, and optionally, in
any sub-directories.
To use this class, create a derived class that implements the abstract
method processFile()
.
Then, create an instance of the derived class and call the
processFiles()
method.
Field Summary | |
---|---|
private File |
mBasePath
Local copy of the path to the base directory to process (as passed into processFiles() . |
private boolean |
mContinueProcessing
Flag indicating whether file processing should continue or stop (set by the value returned from the derived processFile(String, String, String, String)
method.) |
Constructor Summary | |
---|---|
FileWalker()
|
Method Summary | |
---|---|
protected abstract boolean |
processFile(String basePath,
String subPath,
String fileName,
String fileExt)
File processing function. |
private void |
processFiles(File theFile,
boolean subDirs)
Internal recursive directory/file iterating function. |
void |
processFiles(String baseDir,
boolean subDirs)
Process all the files in the specified directory, and optionally in all its sub-directories. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private File mBasePath
processFiles()
.
private boolean mContinueProcessing
processFile(String, String, String, String)
method.)
Constructor Detail |
---|
public FileWalker()
Method Detail |
---|
public void processFiles(String baseDir, boolean subDirs) throws IOException
processFile()
to process any files found.
baseDir
- The base directory containing files to process. subDirs
- A flag that indicates whether files in sub-directories
should also be processed (true
) or not
(false
). IOException
protected abstract boolean processFile(String basePath, String subPath, String fileName, String fileExt)
basePath
- The base path under which the current file was found.
This path will end in a forward slash (/) character to
simplify the construction of a full path/file
specification for the current file.subPath
- The sub-path (if any) under which the current file was
found. As with the base path, this sub-path will end in
a forward slash (/) character to simplify the
construction of a full path/file specification for
the current file. fileName
- The name of the current file (without the extension).
fileExt
- The extension of the current file (if any). If the
current file has an extension, then this string will
begin with a period (.), to simplify the construction
of a full path/file specifiecation for the current file.
true
if file processing should continue, or false
if file processing shouild stop.private void processFiles(File theFile, boolean subDirs) throws IOException
theFile
- The name of the current file/directory to process.
subDirs
- A flag indicating whether or not sub-directories
should be processed. IOException
subDirs
parameter. Once an
actual file is encountered, this method calls the derived
processFile()
method to actually perform some work for the file found.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |