public class ListDirectory extends Object implements DirectoryItemHandler
ListDirectory
lists the contents
of a directory tree in the local filesystem.Constructor and Description |
---|
ListDirectory() |
Modifier and Type | Method and Description |
---|---|
boolean |
handleItem(File f,
int howDeep)
Defines
DirectoryItemHandler . |
void |
ls(String dir,
boolean recurse)
Lists the contents of a directory, optionally listing
the contents of every subdirectory recursivley.
|
public void ls(String dir, boolean recurse)
dir
- the directory to listrecurse
- whether or not to list the contents of
every subdirectory recursively.public boolean handleItem(File f, int howDeep)
DirectoryItemHandler
.
System.out
.
Uses indenting to show the level of the traversal.handleItem
in interface DirectoryItemHandler
f
- the current File being handled by
DirectoryTree.traverse
.howDeep
- how "deep" the traversal is in the tree, with
respect to the root folder in the local
filesystem. (i.e., if the current file is:
/foo/bar/a/b/x.txt
and the root
of the traversal was specified as /foo/bar
,
then howDeep == 2
.)Copyright © 2023. All rights reserved.