How can you write the system's newline character to a file in Java?

What will be an ideal response?

After a String is written, the system's newline character is also written. Although a data file would not require a newline character after each record (each new record could be separated with a comma or any other unique character that was not needed as part of the data), adding a new line makes the output file easier for a person to read and interpret. Because not all platforms use '\n' to separate lines, the BufferedWriter class contains a newLine() method that uses the current platform's line separator. Alternatively, you could write the value of System.getProperty("line.separator "). This method call returns the default line separator for a system; the same separator is supplied either way because the newLine() method actually calls the System.getProperty("line.separator ") method for you.

Computer Science & Information Technology

You might also like to view...

The system is said to be in an unsafe state if ________.

a) the operating system cannot guarantee that all current processes can complete their work within a finite time b) the system is deadlocked c) a thread is indefinitely postponed d) mutual exclusion has been violated

Computer Science & Information Technology

Use a(n) ____________________ when you want to allow only one choice from a list of options.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology