29 Novembre
This commit is contained in:
BIN
DEV3.2/TP7/Repertoires/Main.class
Normal file
BIN
DEV3.2/TP7/Repertoires/Main.class
Normal file
Binary file not shown.
8
DEV3.2/TP7/Repertoires/Main.java
Normal file
8
DEV3.2/TP7/Repertoires/Main.java
Normal file
@@ -0,0 +1,8 @@
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args){
|
||||
Repertoires main = new Repertoires(args[0]);
|
||||
}
|
||||
}
|
BIN
DEV3.2/TP7/Repertoires/Noeud.class
Normal file
BIN
DEV3.2/TP7/Repertoires/Noeud.class
Normal file
Binary file not shown.
62
DEV3.2/TP7/Repertoires/Noeud.java
Normal file
62
DEV3.2/TP7/Repertoires/Noeud.java
Normal file
@@ -0,0 +1,62 @@
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Noeud{
|
||||
private File f;
|
||||
private Noeud n1=null;
|
||||
private Noeud n2=null;
|
||||
private Noeud n3=null;
|
||||
private Noeud n4=null;
|
||||
public Noeud(File s){
|
||||
this.f = s;
|
||||
}
|
||||
/*public Noeud(String s, Noeud noeud1){java.io.File
|
||||
|
||||
}
|
||||
public Noeud(String s, Noeud noeud1, Noeud noeud2, Noeud noeud3){
|
||||
this.f = new File(s);
|
||||
this.noeud1=n1;
|
||||
this.noeud2=n2;
|
||||
this.noeud3=n3;
|
||||
|
||||
}
|
||||
public Noeud(String s, Noeud noeud1, Noeud noeud2, Noeud noeud3, Noeud noeud4){
|
||||
this.f = new File(s);
|
||||
this.noeud1=n1;
|
||||
this.noeud2=n2;
|
||||
this.noeud3=n3;
|
||||
this.noeud4=n4;
|
||||
|
||||
}*/
|
||||
public void add(Noeud n){
|
||||
if(n1!=null){
|
||||
if(n2!=null){
|
||||
if(n3!=null){
|
||||
n4=n;
|
||||
return;
|
||||
}
|
||||
n3=n;
|
||||
return;
|
||||
}
|
||||
n2=n;
|
||||
return;
|
||||
}
|
||||
n1=n;
|
||||
return;
|
||||
}
|
||||
public File getFile(){
|
||||
return this.f;
|
||||
}
|
||||
public Noeud getN1(){
|
||||
return this.n1;
|
||||
}
|
||||
public Noeud getN2(){
|
||||
return this.n2;
|
||||
}
|
||||
public Noeud getN3(){
|
||||
return this.n3;
|
||||
}
|
||||
public Noeud getN4(){
|
||||
return this.n4;
|
||||
}
|
||||
}
|
BIN
DEV3.2/TP7/Repertoires/Repertoires.class
Normal file
BIN
DEV3.2/TP7/Repertoires/Repertoires.class
Normal file
Binary file not shown.
50
DEV3.2/TP7/Repertoires/Repertoires.java
Normal file
50
DEV3.2/TP7/Repertoires/Repertoires.java
Normal file
@@ -0,0 +1,50 @@
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Repertoires{
|
||||
public Repertoires(String s){
|
||||
File f = new File(s);
|
||||
ArrayDeque<File> a = new ArrayDeque<File>();
|
||||
a.add(f);
|
||||
Noeud n=this.tree(a);
|
||||
this.afficher(n,0);
|
||||
}
|
||||
public Noeud tree(ArrayDeque<File> a){
|
||||
File f = a.remove();
|
||||
if(f.isFile()){
|
||||
Noeud n = new Noeud(f);
|
||||
return n;
|
||||
}
|
||||
if(f.isDirectory()){
|
||||
Noeud n = new Noeud(f);
|
||||
File[] liste = f.listFiles();
|
||||
for(int i=0;i<liste.length;i++){
|
||||
a.add(liste[i]);
|
||||
Noeud m=this.tree(a);
|
||||
n.add(m);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public void afficher(Noeud n,int i){
|
||||
String chaine="";
|
||||
for(int j=0;j<i;j++){
|
||||
chaine = chaine+" ";
|
||||
}
|
||||
chaine = chaine+n.getFile().getName();
|
||||
System.out.println(chaine);
|
||||
if(n.getN1()!=null){
|
||||
afficher(n.getN1(),i+1);
|
||||
if(n.getN2()!=null){
|
||||
afficher(n.getN2(),i+1);
|
||||
if(n.getN3()!=null){
|
||||
afficher(n.getN3(),i+1);
|
||||
if(n.getN4()!=null){
|
||||
afficher(n.getN4(),i+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
0
DEV3.2/TP7/Repertoires/toto/dossier 1/fichier 1
Normal file
0
DEV3.2/TP7/Repertoires/toto/dossier 1/fichier 1
Normal file
0
DEV3.2/TP7/Repertoires/toto/dossier 1/fichier 2
Normal file
0
DEV3.2/TP7/Repertoires/toto/dossier 1/fichier 2
Normal file
0
DEV3.2/TP7/Repertoires/toto/dossier 2/fichier 3
Normal file
0
DEV3.2/TP7/Repertoires/toto/dossier 2/fichier 3
Normal file
0
DEV3.2/TP7/Repertoires/toto/fichier 4
Normal file
0
DEV3.2/TP7/Repertoires/toto/fichier 4
Normal file
Reference in New Issue
Block a user