Here you can find the source of write(Document document, OutputStream byteStream)
Parameter | Description |
---|---|
document | A DOM document. |
byteStream | The OutputStream to write to. |
public static void write(Document document, OutputStream byteStream)
//package com.java2s; import java.io.OutputStream; import org.w3c.dom.Document; import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSOutput; import org.w3c.dom.ls.LSSerializer; public class Main { /**//from w w w . ja va 2s.co m * Writes the given document to the given output stream. * * @param document * A DOM document. * @param byteStream * The {@link OutputStream} to write to. */ public static void write(Document document, OutputStream byteStream) { DOMImplementationLS impl = (DOMImplementationLS) document.getImplementation(); LSOutput output = impl.createLSOutput(); output.setByteStream(byteStream); LSSerializer serializer = impl.createLSSerializer(); serializer.getDomConfig().setParameter("format-pretty-print", true); serializer.write(document, output); } }