Here you can find the source of writeDocument(Document doc, Transformer transformer, OutputStream out)
Parameter | Description |
---|---|
doc | a parameter |
transformer | a parameter |
out | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
TransformerException | an exception |
public static void writeDocument(Document doc, Transformer transformer, OutputStream out) throws IOException, TransformerException
//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); } }