File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Performance and the fly likes StringWriter not clear the buffered content Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Performance
Reply 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: 16

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://princecharl.blogspot.com
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 11862
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

Java Resources at www.wbrogden.com
Pene charl
Greenhorn

Joined: Jun 14, 2011
Posts: 16

Thank you william...
 
 
subject: StringWriter not clear the buffered content
 
Threads others viewed
Castor trouble
Getting the error Call Stack as a string
Trying to read a file on Unix into a file on windows or into a string builder
XML doument to a string
XMLSerializer/encoding
IntelliJ Java IDE