Here you can find the source of saveToDisk(Document doc, OutputStream out)
public static void saveToDisk(Document doc, OutputStream out) throws TransformerConfigurationException, TransformerException
//package com.java2s; /* Copyright (c) 2013 Intecs - www.intecs.it. All rights reserved. * This code is licensed under the GPL 3.0 license, available at the root * application directory./*from w ww . ja va2 s . co m*/ */ import java.io.*; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; public class Main { public static void saveToDisk(Document doc, OutputStream out) throws TransformerConfigurationException, TransformerException { Transformer serializer = TransformerFactory.newInstance().newTransformer(); serializer.transform(new DOMSource(doc), new StreamResult(out)); } public static void saveToDisk(Document doc, OutputStream out, boolean indent) throws TransformerConfigurationException, TransformerException { saveToDisk(doc, out); } public static void saveToDisk(Document doc, File file) throws FileNotFoundException, TransformerConfigurationException, TransformerException { saveToDisk(doc, new FileOutputStream(file)); } }