The package that supports stream input/output is java.io, and it is vast. It defines over seventy classes and interfaces, many of which have a large number of methods. It is therefore quite impractical to go into them all in detail in a book of this kind. Refer to the Java documentation for more information. My strategy in this and the following three chapters will be to take a practical approach. The idea is to provide an overall grounding of the concepts involved and to equip you with enough detailed knowledge to be able to do a number of specific, useful, and practical things in your programs. These are:
To be able to read data of various kinds from the keyboard
To be able to create formatted output to the command line
To be able to read and write files containing basic data
To be able to read and write files containing objects
To achieve this, I'll give you an overview of what the important stream classes do and how they interrelate, together with an outline of the classes that operate on streams. I'll go into the detail selectively, just exploring the classes and methods that you need to accomplish specific things. I'll also be sticking to the latest and greatest I/O capability that was first introduced in the JDK 1.4 and continues in JDK 5.0, which makes it unnecessary to delve into a lot of the original stream classes.
Up to and including Java 1.3, the only way to read and write disk files was to use a stream. The new I/O capability ...