wood burning stoves 2.0*
The moose likes Performance and the fly likes StringWriter not clear the buffered content Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "StringWriter not clear the buffered content" Watch "StringWriter not clear the buffered content" New topic
Author

StringWriter not clear the buffered content

Pene charl
Greenhorn

Joined: Jun 14, 2011
Posts: 21

Hi friends,
I have the for loop to generate xml document tree and that has to be stored as string in java.
For storing i have to use stringWriter.
After the single circulation of loop,i need to clear the stringwriter and store new xml string for second circulation..
I had tried with flush() and also getbuffer.setLength(0).
But not succeed .
Please help.


Regards:Prince Charles
http://www.princecharl.blogspot.com
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
A StringWriter object can not be reused or cleared, if you want an empty StringWriter, create a new one.

The flush and close methods are just there to be compatible with java.io.Writer.

Bill
Pene charl
Greenhorn

Joined: Jun 14, 2011
Posts: 21

Thank you william...
 
Consider Paul's rocket mass heater.
 
subject: StringWriter not clear the buffered content
 
Similar Threads
XML doument to a string
Getting the error Call Stack as a string
XMLSerializer/encoding
Castor trouble
Trying to read a file on Unix into a file on windows or into a string builder