I tried searching and couldn't find anything, so I'm sorry if this has been posted before. I need help aligning output at the command line. I want to make even columns, but can't figure out how to do it.

Attached is a screenshot of my current output. I want the code to automatically handle the alignment for nodes 10 and 11, and triple digit numbers if it got that high, and so on and so forth. Is there an output stream class or anything like that that would help me with this?

Attachments Screen_shot_2009-09-16_at_6.26_.56_PM_.png 10.71 KB

I tried searching and couldn't find anything, so I'm sorry if this has been posted before. I need help aligning output at the command line. I want to make even columns, but can't figure out how to do it.

Attached is a screenshot of my current output. I want the code to automatically handle the alignment for nodes 10 and 11, and triple digit numbers if it got that high, and so on and so forth. Is there an output stream class or anything like that that would help me with this?

It's been a while for me, but I imagine NumberFormat might be helpful, as well as printf from the Console class.


http://java.sun.com/docs/books/tutorial/i18n/format/numberintro.html
http://java.sun.com/javase/6/docs/api/java/text/NumberFormat.html
http://java.sun.com/javase/6/docs/api/java/io/Console.html

This question has already been answered. Start a new discussion instead.