Q:

Difference between System.getProperty("line.separator"); and "\n" ?

While developing GUI with Java FX , I seem to get different results with  System.getProperty("line.separator"); and "\n"  during writing to a file or getting data from internet. What basically is the difference ?

A:

System.getProperty("line.separator") returns the OS dependent line separator. 
On Windows it returns "\r\n", on Unix "\n". So if you want to generate a file with line endings for the current operating systems use System.getProperty("line.separator") or write using a PrintWriter.

A:

on the Windows platform, System.getProperty("line.separator") is "\r\n",
"\n" (Linux and MacOS X), "\r" (MacOS 9 and older)

A:

System.getProperty("line.separator") is platform dependent:

"\n" on UNIX style machines
"\r\n" on Windows machines

Whereas "\n" is only "\n".

