I was just perusing through questions, and I found System.getProperty(line.separator)
used in place of \n
with the author's comment that the code was "portable". Reading through various forums, I've seen two groups:
- People who say there's a difference between Linux's and Windows' interpretation of newline characters, and this compensates for that (with no clear evidence).
- People who say there's no difference by showing code and output examples, which obviously only applies to that code example and not universally.
My feeling is: it's probably non-standard OS's, like for example your company's industrial scanner's OS for example, where you'll notice a difference. When am I going to see a difference between \n
and line.separator
? Can you show an example, please? How did you go about discovering where the variation occurs?
\n
, one with\r
and with\n\r
as line endings, open this in NotePad on Windows to see the difference\n
. When Windows users tell you that your program doesn't work, just tell them it doesn't support Windows or pre-OSX Mac and they need to switch to a different system. The Windows way is really quite silly—(just about) no one uses an old-school teletype machine anymore, and Windows end-of-line processing is more complicated for no good reason.