title: from OutputStream to a File Stream
body: <p>I want to save my DOM Document as an XML file. 
  I follow this tutorial: <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXPXSLT4.html" rel="nofollow noreferrer" title="tutorial">http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXPXSLT4.html</a></p>
  
  <p>So, this is my code:</p>
  
  <pre><code>...
  TransformerFactory tFactory = TransformerFactory.newInstance();
  Transformer transformer = tFactory.newTransformer();
  DOMSource source = new DOMSource(doc);
  StreamResult result = new StreamResult(System.out);
  transformer.transform(source, result);
  </code></pre>
  
  <p>but instead of <em>System.out</em>, I want to save in a file the result. How can I do this?</p>