Ask Questions?

View Latest Questions

Advertisement


 
 

Newline Characters
Posted on: July 26, 2006 at 12:00 AM
There are three different major systems for indicating the end of a line.

Java: Newline Characters

There are three different major systems for indicating the end of a line (new line): One for Unix, one for the Macintosh, and one for DOS/Windows.

The '\n' character can be used to represent the single Unicode character with the value 10 ('\u000A').

Windows programs will sometimes accept this, but often need to use a pair of characters (carriage return followed by line feed). Use the method below to get the newline string that is appropriate for your system.

You can get the value for the system your Java program is running on from the system properties. It is important to do this with portable programs.

For example,

 

 

 

 

 

 

 

public static String newline = System.getProperty("line.separator");
Copyleft 2003 Fred Swartz MIT License, Last update: 2003-11-01
Advertisement


DMCA.com