Here you can find the source of dumpToStream(Document doc, OutputStream out)
public static void dumpToStream(Document doc, OutputStream out) throws Exception
//package com.java2s; import java.io.OutputStream; import java.io.PrintWriter; import javax.swing.text.Document; public class Main { public static void dumpToStream(Document doc, OutputStream out) throws Exception { PrintWriter w = new PrintWriter(out); w.print(doc.getText(0, doc.getLength())); w.close();/*from w w w .j a v a 2s . c om*/ out.close(); } }