This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes problem in appending spaces to string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problem in appending spaces to string" Watch "problem in appending spaces to string" New topic
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: 3013
    
  10
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").
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in appending spaces to string