This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am looking at using the Apache Commons Configuration with XML. When I save the configuration it writes out the XML twice. I know I am doing something wrong but can't figure it out. The other odd thing is that it puts out cntrl-Ms on each line (I removed them from the output.)
I checked the API documentation for that XMLConfiguration constructor. It says:
Creates and loads the XML configuration from the specified resource.
Note the words "and loads" there.
As for the "cntrl-M" characters, those are also known as "carriage return" characters. They are perfectly legal whitespace in XML documents. Perhaps this software uses the system default line-endings when it writes XML, and if so then that's what you would see if you ran it on a Windows platform but not on a Unix platform.
(It's more traditional for XML software to use only "line feed" characters on all platforms, since XML parsers are supposed to normalize away the "carriage return" characters, but there's nothing wrong with either version.)
Mike Bates wrote:Ok, I understand now (a bit dense this weekend.)
No, it was just that you had already decided (incorrectly) where the problem was located. That makes it difficult to look elsewhere for the problem, even when somebody specifically points to another location.