Originally posted by Himanshu Khanna:
Hi All ,
I am using StringBuffer for building a row to be written to a file . After writing one row to the file I need empty the StringBuffer object so as to use it again.
I am using strBuf = new StringBuffer() to do this .
Another way possible is delete method of StringBuffer (I think but haven't used ever)
Please advice which way is better keeping issues of performance & memory in mind.
Thanks
"I'm not back." - Bill Harding, Twister
Don't think, but know. Especially when contradicting Jim . The source for the Java libraries is available for download; if you browse it, you'll see in StringBuffer:The code in String reads:The StringBuffer is marked as "shared" and the String is backed by the buffer's char array. StringBuffer methods that actually modify the array will make a copy if it has been marked as shared, so that the String is immutable, e.g.:So, Jim is right.Originally posted by Doco Todd:
I don't think that's true...
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
"I'm not back." - Bill Harding, Twister
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Yup, yup, yup. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|