Here you can find the source of saveDOM(final Document doc, final OutputStream output)
public static void saveDOM(final Document doc, final OutputStream output) throws TransformerException
//package com.java2s; //License from project: Open Source License import java.io.OutputStream; import javax.xml.transform.Transformer; 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 { private static TransformerFactory sTransformerFactory = TransformerFactory.newInstance(); /**//from w w w . ja va 2s. co m * Save a DOM object in a stream */ public static void saveDOM(final Document doc, final OutputStream output) throws TransformerException { final Transformer transformer = sTransformerFactory.newTransformer(); final DOMSource source = new DOMSource(doc); final StreamResult result = new StreamResult(output); transformer.transform(source, result); } }