PrintWriter Java Help

PrintWriter

PrintWriter is essentially a character-oriented version of PrintStream. It provides the .formatted output methods print( ) and println( ). PrintWriter has four constructors.

Iava’s PrintWriter objects support the print( ) and println( ) methods for all types including Object. It.an argument is not a simple type, the PrintWriter methods will call. the object’s toString( ) method and then print opt the result.

Using Stream I/O

TIle following example demonstrates several of Java’s 110 character stream classes and methods. This program Implements the standard we (word COW1t)command, The program has two modes: if no filenames are provided as arguments, the program operates on the standard input stream. If one or more filenames are specified, the program operates on each of them.

When executed with no arguments, WordCount creates an InputStreamReader object using System.in as the source for the stream. This stream is then passed to wet ), which does the actual counting. When executed with one or more arguments, WordCount assumes that these are file names and creates File Readers for each of them, passlength resultant FileReader objects to the we() method. In either case, it prints the results before exiting.

JavaHelpOnline.com

  • Feel free to send us an inquiry, we will reply back in hours.
 

Verification

Posted on September 18, 2014 in Input/output: Exploring java.io

Share the Story

About the Author

Back to Top