Here you can find the source of saveDocument(Document document, File outputFile)
public static void saveDocument(Document document, File outputFile) throws TransformerException
//package com.java2s; /*/* w ww . j a v a 2s. co m*/ * SafeOnline project. * * Copyright 2006 Lin.k N.V. All rights reserved. * Lin.k N.V. proprietary/confidential. Use is subject to license terms. */ import java.io.*; import javax.xml.transform.*; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; public class Main { public static void saveDocument(Document document, File outputFile) throws TransformerException { Source source = new DOMSource(document); Result streamResult = new StreamResult(outputFile); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); transformer.transform(source, streamResult); } }