Here you can find the source of writeDocument(OutputStream stream, Document document)
private static void writeDocument(OutputStream stream, Document document) throws TransformerException
//package com.java2s; /****************************************************************************** * Copyright (c) 2000-2017 Ericsson Telecom AB * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html ******************************************************************************/ import java.io.OutputStream; import javax.xml.transform.Source; 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 void writeDocument(OutputStream stream, Document document) throws TransformerException { Source input = new DOMSource(document); StreamResult output = new StreamResult(stream); TransformerFactory xFormFactory = TransformerFactory.newInstance(); Transformer idTransform = xFormFactory.newTransformer(); idTransform.transform(input, output); }/*from w w w . j a v a 2 s . c o m*/ }