[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: [java] transforming a file to itself - buffered?
Subject: Re: [java] transforming a file to itself - buffered?
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Tue, 04 Jun 2002 22:59:01 +0200
|
Robert Koberg wrote:
What is the best way to handle transforming a file to itself?
Currently I do:
File source = new File(servlet_context.getRealPath(_xml));
transformer.transform(new StreamSource(source), new StreamResult(source));
Opening a file both for reading and writing at the same
time is always risky. Either write to a buffer, and write
the buffer to disk after the transformation has finished,
or write to a temporary file and rename to the original
file afterwards.
Something like;
ByteArrayOutputStream baos=new B...;
File source = new File(servlet_context.getRealPath(_xml));
transformer.transform(new StreamSource(source), new StreamResult(baos));
byte buf[]=baos.toByteArray();
new FileOutputStream(source).write(buf);
BTW doing this in a servlet context appears to be
rather strange...
J.Pietschmann
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|