Java XML Document Save to File saveDOM(final Document doc, final OutputStream output)

Here you can find the source of saveDOM(final Document doc, final OutputStream output)

Description

Save a DOM object in a stream

License

Open Source License

Declaration

public static void saveDOM(final Document doc, final OutputStream output) throws TransformerException 

Method Source Code

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

Related

  1. saveDocumentToFile(Document doc, File file)
  2. saveDocumentToFile(Document doc, String filename)
  3. saveDOM(Document doc, String filename)
  4. SaveDOM(Document document, String filename)
  5. SaveDom(Document dom, String filepath)
  6. saveDomToFile(Document doc, String filePath)
  7. saveHumanReadable(Document document, File file)
  8. saveImpl(Document document, StreamResult output, Properties outputProperties)
  9. saveReportToFile(Node node, String documentFileName)