[jdom-interest] PrintWriter in XMLOutputter

Alex Chaffee guru at edamame.stinky.com
Wed Jun 21 02:29:27 PDT 2000


On Tue, Jun 20, 2000 at 11:45:47AM -0700, Jason Hunter wrote:
> > The one open question in this version is what to use for a line
> > separator. Right now I'm using \r\n since that's most cross-platform
> > compatible and friendliest to various network protocols. However, \n
> > alone might be slightly friendlier to XML parsers. Another
> > possibility is to ask for System.getProperty("line.separator").
> > However, I'm loathe to make the output platform dependent. What do
> > people think?
> > 
> > The value used is stored in a private field called newline so it's
> > easy to change, if it turns out I've made the wrong choice here.
> 
> Another reason to use \r\n over \n is that it'll only cause issues for
> Unix people who tend to be familiar with handling such issues.  In other
> words, every Unix user knows how to remove ^M's, but not every Windows
> user know what to do when Notepad shows one long line.  :-)

Yes, we all know how to clean our bathrooms too, but does that mean we
enjoy it?  I despise seeing ^Ms strewn like dust bunnies around my
files.

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.

I propose that the default EOL for XMLOutputter be "\n" because that's
the Java standard and that the field be public (or rather, that we add
a "setNewline(String)" method) so people with specific IO needs can
get the behavior they want.

-- 
Alex Chaffee                       mailto:alex at jguru.com
jGuru - Java News and FAQs         http://www.jguru.com/alex/
Creator of Gamelan                 http://www.gamelan.com/
Founder of Purple Technology       http://www.purpletech.com/
Curator of Stinky Art Collective   http://www.stinky.com/



More information about the jdom-interest mailing list