Line separators are a funny problem in itself. Each operating system uses different kind of escape sequences to determine a new line.
- Unix/Linux/Mac OS X:
- pre-OSX Mac:
Orignially, the write head of typewriters could only do few tasks. I listed the most important ones below:
- Write symbol and move the cursor one column to the right.
\r| carriage return | CR | Move cursor to the first column of the line.
\n| line feed | LF | Move cursor to the next row/line at the same column.
\b| backspace | BS | Move cursor one column back.
\t| horizontal tab | HT | Move cursor to the next tab-stop.
\r\nescape sequence of windows. Others simplified it by selecting either
In Java, which is plattform independent, you get the plattform dependent escape sequence by obtaining the system property named line.separator.
String lineSeparator = System.getProperty("line.separator");
Other plattform specific system properties as the path.separator (backslash or slash) can be found at this guide.