Chapter 8

Advanced I/O and Exceptions


IT IS AN UNFORTUNATE TRUTH that sometimes when programs are running, errors occur. There are programming errors, such as an array index that is out of the actual range of indices for the array or an attempt to divide a number by zero. Then there are errors over which the programmer has less control or none at all, such as when the user types in a word when the program is expecting a number or when the system runs out of memory.

Often, when an error occurs, the program simply crashes (or worse, goes on to produce incorrect results). However, Java provides a neat mechanism for handling errors and other "exceptional conditions." This exception-handling capability is one of the topics of this chapter. The other topic is Java's built-in input/output facilities, which are implemented through objects called Streams. It turns out to be impossible to use these objects without some understanding of exceptions.


Sections in Chapter 8:

  1. Exceptions, try, and catch
  2. Streams
  3. Files
  4. Networking

[ First Section | Next Chapter | Previous Chapter | Main Index ]