Sources and sinks of data
Almost all of the original Java I/O stream classes have corresponding Reader and Writer classes to provide native Unicode manipulation. However, there are some places where the byte-oriented InputStreams and OutputStreams are the correct solution; in particular, the java.util.zip libraries are byte-oriented rather than char-oriented. So the most sensible approach to take is to try to use the Reader and Writer classes whenever you can, and you’ll discover the situations when you have to use the byte-oriented libraries, because your code won’t compile.
Here is a table that shows the correspondence between the sources and sinks of information (that is, where the data physically comes from or goes to) in the two hierarchies.
Sources & Sinks: Java 1.0 class
|
Corresponding Java 1.1 class
|
InputStream
|
Reader adapter: InputStreamReader
|
OutputStream
|
Writer adapter: OutputStreamWriter
|
FileInputStream
|
FileReader
|
FileOutputStream
|
FileWriter
|
StringBufferInputStream
|
StringReader
|
(no corresponding class)
|
StringWriter
|
ByteArrayInputStream
|
CharArrayReader
|
ByteArrayOutputStream
|
CharArrayWriter
|
PipedInputStream
|
PipedReader
|
PipedOutputStream
|
PipedWriter
|
In general, you’ll find that the interfaces for the two different hierarchies are similar if not identical.