Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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
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: 10170
    
    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: 38007
    
  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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
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