• Post Reply Bookmark Topic Watch Topic
  • New Topic

triming spaces  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I display data in jsp like emp.empcode + "-" + sal.salcode . Sometimes I see values properly displayed like A-B but sometimes I see
A-
C (C in next line). I think this is becoz of spaces. How do I trim these spaces?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You try:

string.trim()

or

string.replaceAll(" ", "");


I think that would work with mny limited Java knowledge!
Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which you would have discovered had you looked in the Javadocs.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!