8.3. The Classes for Input and Output
There are quite a number of stream classes, but as you will see, they form a reasonably logical structure. Once you see how they are related, you shouldn't have much trouble using them. I will work through the class hierarchy from the top down, so you will be able to see how the classes hang together and how you can combine them in different ways to suit different situations.
The package java.io contains the classes that provide the foundation for Java's support for stream I/O:
|InputStream||The base class for byte stream input operations.|
|OutputStream||The base class for byte stream output operations.|
InputStream and OutputStream are both abstract classes. As you are well aware by now, you cannot create instances of an abstract class—these classes serve only as a base from which to derive classes with more concrete input or output capabilities. However, both of the classes declare methods that define a basic set of operations for the streams they represent, so the fundamental characteristics of how a stream is accessed are set by these classes. Both classes implement the Closeable interface. This interface declares just one method, close(), which should close the stream and release any resources that the stream object is holding. Generally, the InputStream and OutputStream classes, and their subclasses, represent byte streams and provide the means of reading and writing binary data as a series of bytes.