Java XML Document to Stream writeDocument(Document doc, Transformer transformer, OutputStream out)

Here you can find the source of writeDocument(Document doc, Transformer transformer, OutputStream out)

Description

write xml document to output stream

License

BSD License

Parameter

Parameter Description
doc a parameter
transformer a parameter
out a parameter

Exception

Parameter Description
IOException an exception
TransformerException an exception

Declaration

public static void writeDocument(Document doc, Transformer transformer,
        OutputStream out) throws IOException, TransformerException 

Method Source Code

//package com.java2s;
/**/*from  w  w  w. j a  v a 2  s .  c o  m*/
 * The contents of this file are subject to the license and copyright
 * detailed in the LICENSE and NOTICE files at the root of the source
 * tree and available online at
 *
 * http://www.dspace.org/license/
 */

import java.io.IOException;
import java.io.OutputStream;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;

import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;

public class Main {
    /**
     *   write xml document to output stream
     * @param doc
     * @param transformer
     * @param out
     * @throws IOException
     * @throws TransformerException
     */
    public static void writeDocument(Document doc, Transformer transformer,
            OutputStream out) throws IOException, TransformerException {
        Source src = new DOMSource(doc);
        Result dest = new StreamResult(out);
        transformer.transform(src, dest);
    }
}

Related

  1. toXml(Document doc, OutputStream out)
  2. write(Document doc, OutputStream out, String enc)
  3. write(Document document, OutputStream byteStream)
  4. writeDocument(Document doc, OutputStream os)
  5. writeDocument(Document doc, OutputStream os)
  6. writeDocument(Document document, OutputStream documentOutputStream)
  7. writeDocument(Document document, OutputStream os)
  8. writeDocument(Document document, OutputStream outputStream)
  9. writeDocument(OutputStream iStream, Element iElement)