[jdom-interest] PrintWriter in XMLOutputter

Elliotte Rusty Harold elharo at metalab.unc.edu
Wed Jun 21 11:26:34 PDT 2000


At 2:29 AM -0700 6/21/00, Alex Chaffee wrote:
>I vaguely remember that \n is defined in Java as representing the
>platform-dependent line ending character(s).  I can't remember where
>this is implemented -- in PrintStream probably --- but I know that
>printing "foo\nbar" does the right thing on all platforms.
>

According to section 3.10.6 of The Java Language Specification 1.0, 
\n means the linefeed character \u000a specifically, not the platform 
dependent line separator. I suppose it's possible PrintStream is 
converting linefeeds to the platform dependent line separator. If so, 
that's VERY, VERY WRONG (breaks all sorts of network protocols and 
what not). I'll have to add it to my list of reasons why PrintStream 
is evil. However, now that XMLOutputter is no longer using 
PrintStream or PrintWriter that shouldn't affect us.

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/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/     |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list