This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to trim a StringBuffer??!!" Watch "how to trim a StringBuffer??!!" New topic
Author

how to trim a StringBuffer??!!

Bharat Macwana
Greenhorn

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: 10167
    
    8

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
Sheriff

Joined: Oct 13, 2005
Posts: 37936
    
  22
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.
 
jQuery in Action, 2nd edition
 
subject: how to trim a StringBuffer??!!
 
Similar Threads
select element as parameter for query
Remove Chars from a String?
classcastexception
How code takes buffer space
How to use trim in StringBuffer