aspose file tools*
The moose likes Beginning Java and the fly likes how to trim a StringBuffer??!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to trim a StringBuffer??!!" Watch "how to trim a StringBuffer??!!" New topic

how to trim a StringBuffer??!!

Bharat Macwana

Joined: May 31, 2007
Posts: 3
Hi Ranchers!!

is this the best way to trim a StringBuffer?

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990

In your code, you are trimming the string and not the buffer.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 36478
You mean s.trim(), surely?

You should usually use StringBuilder instead, and there appears to be a suitable method if you look through its documentation.
I agree. Here's the link:
subject: how to trim a StringBuffer??!!
Similar Threads
How to use trim in StringBuffer
How code takes buffer space
select element as parameter for query
Remove Chars from a String?