public class DirectoryTree extends MTBTree
It is based on a conventional tree data structure, but provides methods for directly parsing a directory structure into the tree. Additionally, the class provides methods for getting a list of all files in all directories below the given root directory.
MTBTree
Modifier and Type | Field and Description |
---|---|
private String |
mainpath
Root directory of the tree.
|
private boolean |
recursiveProcessing
Flag for recursive processing of sub-directories.
|
Constructor and Description |
---|
DirectoryTree(String dir)
Standard constructor.
|
DirectoryTree(String dir,
boolean recursiveFlag)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Vector<String> |
getFileList()
Collect all files in the directory tree including
their complete paths.
|
Vector<String> |
getSubdirectoryList()
Get a list of all subdirectories in the root folder.
|
private void |
initFromDirectory()
Builds the directory tree by initiating the (recursive) parse
procedure.
|
private static MTBTreeNode |
traverseSubdir(String path,
String subdir)
Recursive traversal of subdirectories.
|
clone, cloneChild, getAllNodesDepthFirst, getRoot, printTree
private String mainpath
private boolean recursiveProcessing
public DirectoryTree(String dir)
dir
- Root directory where to begin the parsing.public DirectoryTree(String dir, boolean recursiveFlag)
dir
- Root directory where to begin the parsing.recursiveFlag
- Recursive processing of sub-directories.public Vector<String> getFileList()
public Vector<String> getSubdirectoryList()
Note that the result list includes directory names including their complete absolute paths.
The root folder by itself is not element of the list.
private void initFromDirectory()
private static MTBTreeNode traverseSubdir(String path, String subdir)
path
- Absolute path to parent directory.subdir
- The subdirectory name to be analyzed.Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.