2015-12-15 11:47:04 -08:00
|
|
|
// exceptions/MessyExceptions.java
|
2020-10-07 13:35:40 -06:00
|
|
|
// (c)2020 MindView LLC: see Copyright.txt
|
2015-12-15 11:47:04 -08:00
|
|
|
// We make no guarantees that this code is fit for any purpose.
|
2016-09-23 13:23:35 -06:00
|
|
|
// Visit http://OnJava8.com for more book information.
|
2015-12-15 11:47:04 -08:00
|
|
|
import java.io.*;
|
|
|
|
|
|
|
|
public class MessyExceptions {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
InputStream in = null;
|
|
|
|
try {
|
|
|
|
in = new FileInputStream(
|
|
|
|
new File("MessyExceptions.java"));
|
|
|
|
int contents = in.read();
|
|
|
|
// Process contents
|
|
|
|
} catch(IOException e) {
|
|
|
|
// Handle the error
|
|
|
|
} finally {
|
|
|
|
if(in != null) {
|
|
|
|
try {
|
|
|
|
in.close();
|
|
|
|
} catch(IOException e) {
|
|
|
|
// Handle the close() error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|