-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptionEx.java
More file actions
50 lines (40 loc) · 1.11 KB
/
Copy pathExceptionEx.java
File metadata and controls
50 lines (40 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.sql.SQLException;
import static java.lang.System.out;
public class ExceptionEx {
public static void main(String[] args) {
exception1();
try {
exception2();
} catch (Exception e) {
out.println(e.getMessage());
out.println(e.getCause());
out.println(e.getStackTrace());
}
}
private static void exception2() throws Exception {
try {
out.println("exception2");
throw new Exception("My exception");
} catch (Exception e)
{
out.println("exception2 catch block");
throw e;
}
finally {
out.println("exception2 finally");
}
}
private static void exception1() {
try(FileReader fileReader = new FileReader(new File(""));) {
out.println("exception1");
Class.forName("");
}catch (IOException | ClassNotFoundException ex){
}
finally {
}
}
}