Discussion:
Aligning Output > Columns
(too old to reply)
TheGunslinger
2010-11-07 06:10:26 UTC
Permalink
Does JAVA offer a Format() method for aligning output into defined
columns?

All I am currently using is "\t" to get some spacing, but that doesn't
tab to a column per se.

I need output as starting on a specific columnar tab like in a
wordprocessor. I know this is implemented in C++, but am unable to
find a similar format command in JAVA?

Wanted: (Example: ColumnWidth = 10)
Item amount1 amount2 amount3 etc

versus where spacing depends erratically on the String.length()

item amount1 amount2 amount3 amount4 etc.

TIA,

MJR
David Kerber
2010-11-08 13:24:43 UTC
Permalink
Post by TheGunslinger
Does JAVA offer a Format() method for aligning output into defined
columns?
All I am currently using is "\t" to get some spacing, but that doesn't
tab to a column per se.
I need output as starting on a specific columnar tab like in a
wordprocessor. I know this is implemented in C++, but am unable to
find a similar format command in JAVA?
Wanted: (Example: ColumnWidth = 10)
Item amount1 amount2 amount3 etc
versus where spacing depends erratically on the String.length()
item amount1 amount2 amount3 amount4 etc.
TIA,
MJR
Check to see if java.util.Formatter will do what you want.

D
TheGunslinger
2010-11-08 19:16:24 UTC
Permalink
On Mon, 8 Nov 2010 08:24:43 -0500, David Kerber
Post by David Kerber
Post by TheGunslinger
Does JAVA offer a Format() method for aligning output into defined
columns?
All I am currently using is "\t" to get some spacing, but that doesn't
tab to a column per se.
I need output as starting on a specific columnar tab like in a
wordprocessor. I know this is implemented in C++, but am unable to
find a similar format command in JAVA?
Wanted: (Example: ColumnWidth = 10)
Item amount1 amount2 amount3 etc
versus where spacing depends erratically on the String.length()
item amount1 amount2 amount3 amount4 etc.
TIA,
MJR
Check to see if java.util.Formatter will do what you want.
D
THANKS, I will.

MJR

Loading...