I know that \"printf\" method can use string formatting.
My question is : Is there a way to create a nice looking table with StringBuilder class?
For exampl
Ok, so thank you for all the answer who was nice to me.
I figured out that we could do it by that way :
public String toString(){
StringBuilder s = new StringBuilder();
s.append(String.format("%-20s%-20s%-20s%-20s%-20s%-20s%-20s\n","Identifier","Category","Level","Space","Type","Dimension","Limits"));
s.append(String.format("=============================================================================================================================================\n"));
for(String id : this.idTable.keySet()) {
s.append(String.format("%-20s",id));
s.append(this.idTable.get(id).toString());
//s.append("Identifier: " +id+" "+this.idTable.get(id).toString()+"\n");
}
return s.toString();
}
Notice, the String.format
which do all the work i wanted and didn't know before !
Regardind to you @Marco13, You did a very good job !!!! Thanks all !
P.S.: I will aprove the message from @Marco13 , because his implementation is very good also !