This code:
PrintWriter output = new PrintWriter(new FileWriter(outputFile, false));
output.println("something\n");
output.println("something else\n");
Outputs:
something
something else
Instead of:
something
something else
I tried using "\r\n" instead of just "\n" but it just doesn't work like how I want it to. How do I fix this?
P.S. I'm using windows 7
You can concatenate system's newline to separate your lines:
String newLine = System.getProperty("line.separator");
output.println("something" + newLine);
output.println("something else" + newLine);
Your code works like a charm, just check the file with a proper programmers editor. (or as I suggested before, take a look at an hex dump of the file)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With