Java XML Document to File writeDomToFile(Document doc, String filename)

Here you can find the source of writeDomToFile(Document doc, String filename)

Description

write Dom To File

License

Open Source License

Declaration

public static void writeDomToFile(Document doc, String filename) throws TransformerException 

Method Source Code


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

Related

  1. writeDocument(Document document, String path)
  2. writeDocumentTo(Document doc, File file)
  3. writeDocumentToFile(Document document, String filePathname, String method, int indent)
  4. writeDOM2XMLFile(Document domDoc, String fileName)
  5. writeDOMDocumentToFile(Document doc, String filePath)
  6. writeDomToFile(Document dom, File outFile)
  7. writeDomToFile(Document dom, File outFile)
  8. writeDomToFile(Document dom, File outFile)
  9. writeDomToFile(String filename, Document document)