| Author |
problem in appending spaces to string
|
swapnel surade
Ranch Hand
Joined: Mar 05, 2009
Posts: 129
|
|
hi all,
I have one string to which I have to append few spaces at the end.
I tried to use
but it appending spaces at the start.
is there any way to append spaces at the end of the string.
thanks.
|
 |
harilal ithikkat
Ranch Hand
Joined: Oct 06, 2008
Posts: 221
|
|
now its adding 32 spaces..
will that be ok
|
SCJP 1.5
"A candle looses nothing by lighting another candle"
itechmentors.com
|
 |
Mike Simmons
Ranch Hand
Joined: Mar 05, 2008
Posts: 2782
|
|
|
Swapneel: what you want is "left justification", pushing the string contents up against the left side of the field you've allocated for them. Which means you add spaces on the right side, which is to say, the end of the string. This is achieved in Java string formatting using a '-' flag. Try something like String.format("%-32s", "jack").
|
 |
 |
|
|
subject: problem in appending spaces to string
|
|
|