Java XML Document Save to File saveDocument(Document document, File outputFile)

Here you can find the source of saveDocument(Document document, File outputFile)

Description

save Document

License

Open Source License

Declaration

public static void saveDocument(Document document, File outputFile) throws TransformerException 

Method Source Code


//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);
    }
}

Related

  1. saveDocument(Document doc, File f)
  2. saveDocument(Document doc, File file)
  3. saveDocument(Document doc, File file)
  4. saveDocument(Document doc, String fullFileName)
  5. saveDocument(Document doc, Writer w)
  6. saveDocument(final Document doc, String encoding, String docPath)
  7. saveDocument(final Document document, final File destination)
  8. saveDocument(final Document document, String filename)
  9. saveDocument(String filename, byte[] document)