Here you can find the source of elementToStream(Element element, OutputStream out)
public static void elementToStream(Element element, OutputStream out) throws TransformerException
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; 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 java.io.OutputStream; public class Main { public static void elementToStream(Element element, OutputStream out) throws TransformerException { DOMSource source = new DOMSource(element); StreamResult result = new StreamResult(out); TransformerFactory transFactory = TransformerFactory.newInstance(); Transformer transformer = transFactory.newTransformer(); transformer.transform(source, result); }/*from ww w. java 2 s. c o m*/ }