Java Reader and Writer Character Streams

Introduction

The byte stream classes cannot work directly with Unicode characters.

Java supports the character I/O via the character stream.

On the top of character stream hierarchies are the Reader and Writer abstract classes.

Reader

Reader is an abstract class that defines Java's model of streaming character input.

It implements the AutoCloseable , Closeable, and Readable interfaces.

Writer

Writer is an abstract class that defines streaming character output.

It implements the AutoCloseable , Closeable, Flushable, and Appendable interfaces.

Input and output streams are byte-based streams. Readers and writers are character-based streams.

The following table lists Classes in Byte-based and Character-based Input Streams

Byte-based Input Stream Class Character-based Input Stream Class
InputStream Reader
ByteArrayInputStream CharArrayReader
StringBufferInputStream StringReader
PipedInputStream PipedReader
FileInputStream FileReader
No corresponding classInputStreamReader
FilterInputStream FilterReader
BufferedInputStream BufferedReader
PushbackInputStream PushbackReader
DataInputStream No corresponding class
ObjectInputStream No corresponding class
OutputStream Writer
ByteArrayOutputStreamCharArrayWriter
No corresponding class StringWriter
PipedOutputStreamPipedWriter
FileOutputStream FileWriter
No corresponding class OutputStreamWriter
FilterOutputStream FilterWriter
BufferedOutputStream BufferedWriter
DataOutputStream No corresponding class
ObjectOutputStream No corresponding class
PrintStream PrintWriter



PreviousNext

Related