APL/DEV 3.2/TP07/Repertoires/Repertoires.java

27 lines
678 B
Java
Raw Normal View History

2022-11-24 15:17:33 +01:00
import java.io.File;
/**
* Repertoires
*/
public class Repertoires {
public static void main(String[] args) {
Tree<String> tree = new Tree<>();
File f = new File(args.length > 0 ? args[0] : ".");
tree.getRootNode().setValue(f.getName());
fillNode(tree.getRootNode(), f);
tree.showTree();
}
public static void fillNode(Node<String> node, File folder) {
for (File f : folder.listFiles()) {
Node<String> subNode = new Node<String>(f.getName());
if (f.isDirectory()) {
fillNode(subNode, f);
}
node.addSubNode(subNode);
}
}
}