Java is the future !: Line separator in Java

Monday, October 25, 2010

Line separator in Java

 Different operating systems use different conventions to mark the ends of lines in text files. 
  • Windows/DOS uses [CrLf] [\r\n] [0x0d 0x0a] to terminate each line.
  • The web, Unix, Linux and Mac OS uses [Lf] [\n] [0x0a] to terminate each line.
  • The older Mac OS 1-9 uses [Cr] [\r] [0x0d] to terminate each line.
If you use the readLine and println methods, Java automatically deals with the platform differences for you.

No comments:

Post a Comment