mardi 24 mars 2015

java formatter output incorrect


Vote count:

0





try {
FileWriter writer = new FileWriter("metrics.csv");
Formatter fmt = new Formatter();
fmt.format(
"%10s%10s%10s%10s%10s%10s%10s%10s%10s%10s%10s%3s", "",
"ANA", "NOM", "NOA", "ITC", "ETC", "CAC", "DIT",
"CLD", "NOC", "NOD", ",\n");
for(int i = 0;i< class_list.getModel().getSize(); i++){
fmt.format(
"%10s%10s%10s%10s%10s%10s%10s%10s%10s%10s%10s%3s", declaration.getClassesName().get(i),
declaration.getANA(i), declaration.getNOM(i), declaration.getNOA(i), declaration.getITC(i), declaration.getETC(i), declaration.getCAC(i), declaration.getDIT(i),
declaration.getCLD(i), declaration.getNOC(i), declaration.getNOD(i), ",\n");
}
writer.append(fmt.toString());
writer.flush();
writer.close();
System.out.println("done");
} catch (IOException ioe) {
ioe.printStackTrace();
}


all get functions return a string which length is smaller than 10. The output that i get is:




ANA NOM NOA ITC ETC CAC DIT CLD NOC NOD ,
Equipe 0.33
3 1 1 1 3 0 0 0 0 ,
Participant 0.0
1 1 0 0 0 0 1 2 2 ,
Joueur 0.33
3 3 0 1 1 1 0 0 0 ,
Entraineur 0.0
1 2 0 0 1 1 0 0 0 ,
Stade 2.0
1 2 1 0 1 0 0 0 0 ,


as you can see, the column is not aligned. Anyone knows where is the problem in my code? Thanks.



asked 1 min ago







java formatter output incorrect

Aucun commentaire:

Enregistrer un commentaire