Java Reference
In-Depth Information
CHAPTER
14
E
XCEPTION
H
ANDLING
AND
T
EXT
I/O
Objectives
To get an overview of exceptions and exception handling (§14.2).
■
To explore the advantages of using exception handling (§14.2).
■
To distinguish exception types:
Error
(fatal) vs.
Exception
(nonfatal)
and checked vs. unchecked (§14.3).
■
To declare exceptions in a method header (§14.4.1).
■
To throw exceptions in a method (§14.4.2).
■
To write a
try-catch
block to handle exceptions (§14.4.3).
■
To explain how an exception is propagated (§14.4.3).
■
To obtain information from an exception object (§14.4.4).
■
To develop applications with exception handling (§14.4.5).
■
To use the
finally
clause in a
try-catch
block (§14.5).
■
To use exceptions only for unexpected errors (§14.6).
■
To rethrow exceptions in a
catch
block (§14.7).
■
To create chained exceptions (§14.8).
■
To define custom exception classes (§14.9).
■
To discover file/directory properties, to delete and rename files/directories,
and to create directories using the
File
class (§14.10).
■
To write data to a file using the
PrintWriter
class (§14.11.1).
■
To read data from a file using the
Scanner
class (§14.11.2).
■
To understand how data is read using a
Scanner
(§14.11.3).
■
To develop a program that replaces text in a file (§14.11.4).
■
To open files using a file dialog box (§14.12).
■
To read data from the Web (§14.13).
■