Page 135 -
P. 135
files and exceptions
So, which approach is best?
Well…it depends on who you ask! Here are both versions of your code:
This version uses extra logic
to handle File I/O errors.
This version uses another “try”
statement to handle File I/O errors.
Let’s ask a simple question about these two versions of your program: What do each
of these programs do?
Grab your pencil. In box 1, write down what you think the
program on the left does. In box 2, write down what you think
the program on the right does.
1
2
you are here 4 99