This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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 Java 8 in Action this week in the Java 8 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://princecharl.blogspot.com
William Brogden
Author and all-around good cowpoke
Rancher

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

Java Resources at www.wbrogden.com
Pene charl
Greenhorn

Joined: Jun 14, 2011
Posts: 21

Thank you william...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: StringWriter not clear the buffered content
 
Similar Threads
Trying to read a file on Unix into a file on windows or into a string builder
XML doument to a string
Castor trouble
Getting the error Call Stack as a string
XMLSerializer/encoding