Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

String trim() method

807580Oct 14 2009 — edited Oct 14 2009
Hi all,
I use MS SQL Server and I have a table with the currency column of type: char(10). The currency is usually 3 chars like: USD; however looks like since the column type is of type: char(10), the database it adds up extra spaces at the end in order to make the length of Char to 10, so the "USD" becomes "USD ".

I use ResultSet.getString() method in order to read the column from ResultSet. In order to get rid of the extra spaces at the end, I use String.trim() method however, it looks like it does NOT get rid of extra spaces as expected or I should better say the behavior is random as sometimes the String I get after I used the trim() method is “USD” and other times is: “USD “.

Does anybody know why it’s happening?
Is there any other method I can use that gets rid of extra spaces?

Any help is greatly appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 11 2009
Added on Oct 14 2009
8 comments
1,470 views