go to previous page   go to home page   go to next page

Answer:

No.


PrintWriter

printWriter Pipe

Different operating systems separate lines in text files in different ways. To the annoyance of programmers everywhere, Microsoft operating systems use a two byte sequence at the end of a line of text, but Unix (and Linux) operating systems use just one byte.

The class PrintWriter is used to deal with the end-of-line problem and other frustrations of file output. PrintWriter provides many methods that are useful for "printing" characters. ("Printing" in this context means sending characters to an output destination, not usually a hard-copy printer.) The println() method uses the appropriate line separator for the operating system the program is running on.

Often a PrintWriter stream is connected to a BufferedWriter stream which is connected to a FileWriter.

For small programs, where buffering is not needed, the middle pipe (the BufferedWriter) can be omitted.

A further advantage of PrintWriter is that none of its methods (including println()) throw exceptions. Usually output is more reliable than input (because the program has control over its output), so exception handling is sometimes not needed.


QUESTION 14:

Can a PrintWriter be used alone?