Java-Reader and Writer Classes

Reader and Writer Classes

The Reader and Writer classes and their subclasses are used for dealing with data in text format. While the Writer class contains methods that are identical to those available in OutputStream class, the Reader class contains methods that are identical to those available in InputStream class. The only difference is that the methods in the Writer and Reader classes are designed to deal with character input/output, while the corresponding methods in the OutputStream and InputStream classes are designed to deal with byte input/output.

Important Subclasses of Writer Class

Name of the Class Functionality
BufferedWriter Buffering output
CharArrayWriter Writing to an array
FilterWriter Filtering the output
OutputStreamWriter Translating character stream into a byte stream
FileWriter Writing to a file
PrintWriter Printing values and objects
PipedlnputStream Reading from a pipe
PipedWriter Writing to a pipe
StringWriter Writing to a String

Important Subclasses of Reader Class

Name of the Class Functionality
BufferedReader Buffering input
LineNumberReader Keeping track of line numbers
CharArrayReader Reading from an array
InputStreamReader Translating byte stream into a character stream
FileReader Reading from a file
FilterReader Filtering the input
PushbackReader Pushing back a character to the stream
PipedReader Reading from a pipe
StringReader Reading from a string

Leave a Comment