• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in appending spaces to string  RSS feed

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

now its adding 32 spaces..
will that be ok
 
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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").
 
Maybe he went home and went to bed. And took this tiny ad with him:
The WEB SERVICES and JAX-RS Course
https://coderanch.com/t/690789/WEB-SERVICES-JAX-RS
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!