from OutputStream to a File Stream

Posted by Gabriele on Stack Overflow See other posts from Stack Overflow or by Gabriele
Published on 2010-06-15T17:31:11Z Indexed on 2010/06/15 17:32 UTC
Read the original article Hit count: 198

Filed under:
|

I want to save my DOM Document as an XML file. I follow this tutorial: http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXPXSLT4.html

So, this is my code:

...
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(System.out);
transformer.transform(source, result);

but instead of System.out, I want to save in a file the result. How can I do this?

© Stack Overflow or respective owner

Related posts about java

Related posts about Xml