The Stream Classes
Java’s stream-based I/O is built upon four abstract classes: Inputstream, OutputStream, Reader, and Writer. These classes were briefly discussed in Chapter 12.They arc used to create several concrete stream subclasses. Although YOU’ll’ programs perform their I/O operations through concrete SUbclasses,the top-level classes define the basic functionality common to all stream classes.
InputStream and OutputStream arc designed for byte streams. Reader and Writer are designed for character streams. The byte stream classes and the character stream classes form separate hierarchies.In general, you should use the character stream classes then working with characters or strings, and use the byte stream classes when working with bytes or other binary objects.
In the remainder of this chapter, both the byte- and character-oriented streams are examined.
The Byte Stream
The byte stream classes provide a rich environment for handling byte-oriented L/O. A byte stream can be used with any type of object, including binary data. nus versatility makes byte streams important to many types of programs. Since the byte stream classes are topped by InputStream and Outputstream, our discussion will begin with them.