This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
You need to adapt your linebreaks according to your intended platform. Windows uses "\r\n" (i.e. 13 and 10), Unix just "\n" (and Mac OS 9 and earlier just "\r", for the terminally curious). There's also a system property called line.separator that you can use for this, assuming your generating and consuming platforms are identical.
Most importantly: Notepad, unlike many Windows programs, is incapable of properly displaying text files with UNIX line endings. For notepad to read a file, it must contain line endings consisting of the two characters 0x13, 0x10 (or ^M^J, or \r\n, or however you like to write it). Nothing else will do.
I'd already tried \n and \r. I gave System.getProperty("line.separator") a go and I got exactly the same result.
The odd thing is that the unrecognisable character is code 10 (I checked it in MS Excel). But the good line breaks (e.g., like after "original line 2") are also code 10.
So how come my code 10's are not good enough?!
Also, the server and client platforms are not identical, I think the servlet is sitting on a Unix server. I am Windows, and I've not idea about the Motorola... But it seems this is definately something to do with it.
author and iconoclast
It's \r \n, not \n \r. Makes a difference! Also, the line.separator property gives the separator appropriate for the platform the program is on -- in this case, a UNIX server, not the Windows client. Seriously, do what I said: use the two characters "\r \n", in that order.
Joined: Jan 22, 2004
Never heard of "\r\n" - I just presumed it was a typo!...