Hi Mesut,
as a workaround I would implement my own StringWriter that has a clear()
method to clean the internal buffer. This should be a quite easy task.
Ralf
mesut çelik schrieb:
Hi all,
I use StringWriter in the XMLSerializer as a writer object. However, If
i reuse my marshaller object , everytime during marshalling, it appends
new serialized String into StringWriters buffer. I tried to call flush()
and close() methods but they dont work.
This is the code sample:
writer=new StringWriter();
format = new OutputFormat();
format.setOmitXMLDeclaration(true);
format.setIndenting( true );
format.setIndent( 4 ); // 2-space indention
format.setLineWidth( 16384 ); // As large as needed to prevent
linebreaks in
format.setLineSeparator( System.getProperty( "line.separator" ) );
serializer = new XMLSerializer( writer , format );
marshaller = new Marshaller(serializer.asContentHandler());
while(somecondition)
{
marshaller.marshal(object);
String xml=writer.toString(); //in each loop new serialized xml appended
the old one
writer.flush();// doesnot work since it’s empty in jdk.
}
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------