43 lines
875 B
Java
43 lines
875 B
Java
import java.io.File;
|
|
|
|
public class Repertoires {
|
|
|
|
private File val;
|
|
private Noeud son;
|
|
|
|
public Repertoires(File root) {
|
|
try {
|
|
if(!root.isDirectory()) {
|
|
this.val = root;
|
|
} else {
|
|
this.son = new Noeud();
|
|
this.val = root;
|
|
try {
|
|
for(File files : root.listFiles()) {
|
|
this.son.add(new Repertoires(files));
|
|
}
|
|
}catch(SecurityException e2) {
|
|
System.err.println("access to read the directory was denied : "+e2);
|
|
}
|
|
}
|
|
} catch(SecurityException e1) {
|
|
System.err.println("the file you gave is not a directory : "+e1);
|
|
}
|
|
}
|
|
|
|
/*
|
|
public void fileToString() {
|
|
String stringFile = "";
|
|
|
|
for(int i = 0; i != file.getName().length(); i++) {
|
|
stringFile = ""+file.getPath();
|
|
}
|
|
|
|
return stringFile;
|
|
}
|
|
*/
|
|
|
|
public static void main(String[] args) {
|
|
Repertoires file = new Repertoires(new File(args[0]));
|
|
}
|
|
} |