Here you can find the source of writeDocument(Document document, OutputStream documentOutputStream)
Parameter | Description |
---|---|
document | DOM document |
documentOutputStream | output stream |
Parameter | Description |
---|---|
TransformerFactoryConfigurationError | transformer config error |
TransformerException | transformer error |
IOException | IO error |
public static void writeDocument(Document document, OutputStream documentOutputStream) throws TransformerFactoryConfigurationError, TransformerException, IOException
//package com.java2s; /*/*w ww .j a va 2 s . co m*/ * eID Identity Provider Project. * Copyright (C) 2010 FedICT. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version * 3.0 as published by the Free Software Foundation. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, see * http://www.gnu.org/licenses/. */ 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.TransformerFactory; import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; public class Main { /** * Write the DOM {@link Document} to specified {@link OutputStream} * * @param document * DOM document * @param documentOutputStream * output stream * @throws TransformerFactoryConfigurationError * transformer config error * @throws TransformerException * transformer error * @throws IOException * IO error */ public static void writeDocument(Document document, OutputStream documentOutputStream) throws TransformerFactoryConfigurationError, TransformerException, IOException { Result result = new StreamResult(documentOutputStream); Transformer xformer = TransformerFactory.newInstance() .newTransformer(); Source source = new DOMSource(document); xformer.transform(source, result); } }