all (flemme)
This commit is contained in:
32
DEV/DEV3.2/TP_Tree1/Exercise1/DirectoryList.java
Normal file
32
DEV/DEV3.2/TP_Tree1/Exercise1/DirectoryList.java
Normal file
@@ -0,0 +1,32 @@
|
||||
import java.io.File;
|
||||
|
||||
class DirectoryList {
|
||||
|
||||
public static void main(String[] args) {
|
||||
if(args.length == 0) {
|
||||
System.err.println("Usage: DirectoryList <repository_name>");
|
||||
return;
|
||||
}
|
||||
|
||||
String repositoryName = args[0];
|
||||
|
||||
File directory = new File(repositoryName);
|
||||
|
||||
if(!directory.exists()) {
|
||||
System.err.println("Repository not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println(directory.getName());
|
||||
listFiles(directory, "\t");
|
||||
}
|
||||
|
||||
private static void listFiles(File directory, String space) {
|
||||
if(!directory.isDirectory() || directory.listFiles().length == 0) return;
|
||||
|
||||
for(File file : directory.listFiles()) {
|
||||
System.out.println(space + file.getName());
|
||||
listFiles(file, space + '\t');
|
||||
}
|
||||
}
|
||||
}
|
||||
8
DEV/DEV3.2/TP_Tree1/Exercise1/Node.java
Normal file
8
DEV/DEV3.2/TP_Tree1/Exercise1/Node.java
Normal file
@@ -0,0 +1,8 @@
|
||||
public class Node {
|
||||
private String name;
|
||||
private Node[] children;
|
||||
|
||||
public Node(String name) {
|
||||
|
||||
}
|
||||
}
|
||||
0
DEV/DEV3.2/TP_Tree1/Exercise1/tp/answer.txt
Normal file
0
DEV/DEV3.2/TP_Tree1/Exercise1/tp/answer.txt
Normal file
0
DEV/DEV3.2/TP_Tree1/Exercise1/tp/tp1/content.txt
Normal file
0
DEV/DEV3.2/TP_Tree1/Exercise1/tp/tp1/content.txt
Normal file
Reference in New Issue
Block a user