[jdom-interest] XMLOutputter & StringWriter

Gabor Greif gabor at no.netopia.com
Thu Jun 29 06:24:15 PDT 2000


Judging from the below snippet (taken from XMLOutputter.java)
the output method took a PrintWriter in its earlier life.

This seems to be a docu bug BTW (also in other locations).

What I want to do is to write the document into a java.io.StringWriter so
that I can capture the string and display it in a Swing component.
Understandably I do not want it written into an encoded _byte_ stream.

Has anybody needed something like this before? How to do it?
I guess adding
public void output(Document doc, java.io.StringWriter out)
would be easy, but maybe there is a sanctioned way to do it?

	Thanks,

	Gabor



    /**
     * <p>
     * This will print the <code>Document</code> to the given output
stream.
     *   The characters are printed using UTF-8 encoding.
     * </p>
     *
     * @param doc <code>Document</code> to format.
     * @param out <code>PrintWriter</code> to write to.
     * @param encoding set encoding format.
     * @throws <code>IOException</code> - if there's any problem writing.
     */
    public void output(Document doc, OutputStream out, String encoding)
                                           throws IOException {
        this.encoding = encoding;
        output(doc, out);
    }







More information about the jdom-interest mailing list