[jdom-interest] PrintWriter in XMLOutputter

Brett McLaughlin brett.mclaughlin at lutris.com
Mon Jun 19 14:46:26 PDT 2000


Elliotte Rusty Harold wrote:
> 
> I'm looking at XMLOutputter right now, and I'm wondering why it makes
> such heavy use of PrintWriter? It doesn't seem to really need it, and
> this has the, to my mind, nasty effect of hiding any IOExceptions that
> may occur when the document is written. For instance, if I'm writing to
> a network socket and the phone company cuts off my phone line in the
> middle of my write, I won't get notified that the write failed.
> 
> Wouldn't it be better to use OutputStreamWriter instead, which doesn't
> suppress IOExceptions, so that programmers will be warned if their
> writes fail? The output() method is already declared to throw
> IOExceptions, so this is not an API change for the public API, but in
> practice output() will almost never throw an IOException as currently
> written. The protected API would have to change but that's a relatively
> minor loss.

I'm OK with this - particuarly from our lauded "Network Programming" and
"I/O" guy ;-) XMLOutputter was around class #5 or so that we wrote, so
it's plausible, if not probable, that it isn't bulletproof - Jason, you
wrote most of that code, do you concur with Elliotte? If so, Elliotte,
you want to take that one?

Thanks,
Brett

> 
> --
> +-----------------------+------------------------+-------------------+
> | Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
> +-----------------------+------------------------+-------------------+
> |               Java I/O (O'Reilly & Associates, 1999)               |
> |            http://metalab.unc.edu/javafaq/books/javaio/            |
> |   http://www.amazon.com/exec/obidos/ISBN=1565924851/cafeaulaitA/   |
> +----------------------------------+---------------------------------+
> |  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
> |  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |
> +----------------------------------+---------------------------------+
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

-- 
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 
http://www.lutris.com
http://www.enhydra.org



More information about the jdom-interest mailing list