Here you can find the source of writeDomToFile(Document doc, String filename)
public static void writeDomToFile(Document doc, String filename) throws TransformerException
//package com.java2s; import java.io.File; 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 { public static void writeDomToFile(Document doc, String filename) throws TransformerException { TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(doc); StreamResult streamResult = new StreamResult(new File(filename)); transformer.transform(source, streamResult); }//from w w w . ja v a 2 s . co m }