Reader
Reader is the abstract class for reading character streams.
The following table lists the reader and writer classes which deal with the character based stream.
BufferedReader
- Buffered input character stream
BufferedWriter
- Buffered output character stream
CharArrayReader
- Input stream that reads from a character array
CharArrayWriter
- Output stream that writes to a character array
FileReader
- Input stream that reads from a file
FileWriter
- Output stream that writes to a file
FilterReader
- Filtered reader
FilterWriter
- Filtered writer
InputStreamReader
- Input stream that translates bytes to characters
LineNumberReader
- Input stream that counts lines
OutputStreamWriter
- Output stream that translates characters to bytes
PipedReader
- Input pipe
PipedWriter
- Output pipe
PrintWriter
- Output stream that contains print( ) and println( )
PushbackReader
- Input stream that allows characters to be returned to the input stream
Reader
- Abstract class that describes character stream input
StringReader
- Input stream that reads from a string
StringWriter
- Output stream that writes to a string
Writer
- Abstract class that describes character stream output
The Predefined Streams
System.out refers to the standard output stream. By default, this is the console. System.in refers to standard input, which is the keyboard by default. System.err refers to the standard error stream, which also is the console by default. System.in is an object of type InputStream; System.out and System.err are objects of type PrintStream.
The following methods are defined by Reader.
abstract void close()
- Closes the stream and releases any system resources associated with it.
void mark(int readAheadLimit)
- Marks the present position in the stream.
boolean markSupported()
- Tells whether this stream supports the mark() operation.
int read()
- Reads a single character.
int read(char[] cbuf)
- Reads characters into an array.
abstract int read(char[] cbuf, int off, int len)
- Reads characters into a portion of an array.
int read(CharBuffer target)
- Attempts to read characters into the specified character buffer.
boolean ready()
- Tells whether this stream is ready to be read.
void reset()
- Resets the stream.
long skip(long n)
- Skips characters.
Revised from Open JDK source code