Java Reference
In-Depth Information
5.
A
File
object describes a file or directory.
6.
You can pass a
File
object to the constructor of a file reader, writer, or stream.
7.
When you launch a program from the command line, you can specify
arguments after the program name. The program can access these strings by
processing the
args
parameter of the
main
method.
8.
To signal an exceptional condition, use the
throw
statement to throw an
exception object.
9.
When you throw an exception, the current method terminates immediately.
10. There are two kinds of exceptions: checked and unchecked. Unchecked
exceptions extend the class
RuntimeException
or
Error
.
11. Checked exceptions are due to external circumstances that the programmer
cannot prevent. The compiler checks that your program handles these
exceptions.
12. Add a
throws
specifier to a method that can throw a checked exception.
13. In a method that is ready to handle a particular exception type, place the
statements that can cause the exception inside a
try
block, and the handler
inside a
catch
clause.
14. It is better to declare that a method throws a checked exception than to handle
the exception poorly.
15. Once a
try
block is entered, the statements in a
finally
clause are
guaranteed to be executed, whether or not an exception is thrown.
16. You can design your own exception typesČsubclasses of
Exception
or
Runtime-Exception
.
521
522
CLASSES, OBJECTS, AND METHODS INTRODUCED IN THIS
CHAPTER
java.io.EOFException
java.io.File