Java XML Document to Stream writeDocument(OutputStream stream, Document document)

Here you can find the source of writeDocument(OutputStream stream, Document document)

Description

write Document

License

Open Source License

Declaration

private static void writeDocument(OutputStream stream, Document document) throws TransformerException 

Method Source Code

//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*/
}

Related

  1. writeDocument(Document document, OutputStream os)
  2. writeDocument(Document document, OutputStream outputStream)
  3. writeDocument(OutputStream iStream, Element iElement)
  4. writeDocument(OutputStream os, Document document)
  5. writeDocument(OutputStream os, Node node)
  6. writeDOMDocumentToStream(Document doc, OutputStream stream)
  7. writeOutDocument(OutputStream os, Document doc)
  8. writeTransformedXml(Document doc, OutputStream output, InputStream style)
  9. writeXerces(Document doc, OutputStream out, String encoding)