Bonjour à toutes et à tous

Je voudrai avoir en sortie un fichier CSV sous forme de tableau comme excel.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
class Personne
   public String  nom;
   public Voiture voiture
 
   public Personne(String nom, Voiture v){
       this.nom=nom;
       this.voiture=v;
 }
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
public class Voiture {
   public String nom;
   public Marque marque;
   public Voiture(String nom,Marque m){
       this.nom=nom;
       this.marque=m;
  }
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
public class Marque {
     public String nom;
     public Marque(String nom){
        this.nom=nom;
     }
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
public class FileDemo {
 
	List<Personne> listsP = new ArrayList<Personne>();
 
        private void recapGlobalCSV() throws IOException {
           File csvFile = new File("C:\\recapGlobalResynchro.csv");
           PrintStream ficOut = null;
           if (!csvFile.exists()) {
            try {
                csvFile.createNewFile();
                ficOut = new PrintStream(new FileOutputStream(csvFile, true));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        StringBuffer pltf= new StringBuffer(";");
        for (Personne p: listsP ) {
        	pltf.append(p.voiture.marque.nom + ";");
 
 
        }
        ficOut.print(pltf);
        ficOut.println();
    }
 
	public String retrieveEquivalent(String marque){
		StringBuffer fic = new StringBuffer();
                 boolean find= false;
                for (Personne p: listsP ) {
             if(p.voiture.marque.nom(marque) && !find){
            	fic.append(p.voiture.marque.nom + ";");
                find=true;
            }     
        }
        return fic.toString();
    }
        public static void main(String[] args) {
 
         FileDemo file= new FileDemo();
 
	   Marque m1 = new Marque ("Renault");
	   Voiture v1 = new Voiture ("Megane",m1);
 
	   Marque m2 = new Marque ("Citroen");
	   Voiture v2 = new Voiture ("Xara",m2);
 
	   Marque m3 = new Marque ("Mercedes");
	   Voiture v2 = new Voiture ("CLK",m3);
 
	   Personne p1= new Personne ("Dupont",v1);
	   Personne p2= new Personne ("Durant",v2);
	   Personne p3= new Personne ("TOTO",v3);
 
	   file.listsP .add(p1);
	   file.listsP .add(p2);
	   file.listsP .add(p3);
 
	   try {
		file.recapGlobalCSV();
	} catch (IOException e) {
		e.printStackTrace();
	}
Je veux produire un fichier CSV de la sorte :



Nom : Untitled.png
Affichages : 313
Taille : 5,0 Ko
Cordialement