Java Reference
In-Depth Information
Exception
IOException
CharConversionException
EOFException
FileNotFoundException
InterruptedIOException
ObjectStreamException
InvalidClassException
InvalidObjectException
NotActiveException
StreamCorruptedException
WriteAbortedException
FIGURE 11-4
The
class
IOException
and some of
its subclasses from the
package
java.io
The
class
Exception
is the superclass of the classes designed to handle exceptions.
There are various types of exceptions, such as I/O exceptions, input mismatch
exceptions, number format exceptions, file not found exceptions, and array index
out of bounds exceptions. Java categorizes these exceptions into separate classes.
These predefined exception classes are contained in various packages. The
class
Exception
is contained in the
package
java.lang
.TheclassestodealwithI/O
exceptions, such as the file not found exception, are contained in the
package
java.io
.Similarly,theclassestodealwithnumber format exceptions and arithmetic
exceptions, such as division by zero, are contained in the
package
java.lang
.
Generally, exception classes are placed in the package that contains the methods that
throw these exceptions.
The
class
Exception
is very simple. It only contains two constructors, as shown in
Table 11-2.
Search WWH ::
Custom Search