Java - OS independent line separator

 You might already knew, the new line character depends on your OS.
  • \n for Unix
  • \r\n for Windows and 
  • \r for old Macs
  • and so on

Always use
System.getProperty("line.separator")
OR
Java 7's way: System.lineSeparator()

This will let you find out OS specific line separator instead of judging yourself and hard coding it. It also helps you in avoiding bugs.

Bonus information:
The new line characters originated from the old type writer era.
  • Carriage return - CR = \r
  • Line feed - LF = \n
Read wikipedia article for more information about new line characters.