With exception handling.
- By Matt Brenner
- September 24, 2001
Lab Notes
Clarifying exception handling
by Matt Brenner
Listing 4. With exception handling.
1 private void
2 addlist (String listname, boolean uppercase)
3 {
4 BufferedReader input = null;
5
6 String text;
7
8
9 try {
10 input = new BufferedReader (new FileReader (new File (Setup.getinstalldir(), listname)));
11 while ((text = input.readLine()) != null) {
12 if (text.length() > 0) {
13 add (text, uppercase);
14 }
15 }
16 }
17 catch (IOException e) {
18 Errorlog.log (Syserrors.error (BLOCKLIST1, e.toString()));
19 }
20 finally {
21 if (input != null) {
22 try {
23 input.close();
24 }
25 catch (IOException e) {}
26 }
27 }
28 }