forked from jhipster/prettier-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_output.java
More file actions
82 lines (75 loc) · 2.38 KB
/
_output.java
File metadata and controls
82 lines (75 loc) · 2.38 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
public class TryCatch {
void tryFinally() {
try {
System.out.println("Try something");
} finally {
System.out.println("Finally do something");
}
}
void tryCatch() {
try {
System.out.println("Try something");
} catch (ArithmeticException e) {
System.out.println("Warning: ArithmeticException");
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Warning: ArrayIndexOutOfBoundsException");
} catch (Exception e) {
System.out.println("Warning: Some Other exception");
}
}
void tryCatchFinally() {
try {
System.out.println("Try something");
} catch (ArithmeticException e) {
System.out.println("Warning: ArithmeticException");
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Warning: ArrayIndexOutOfBoundsException");
} catch (Exception e) {
System.out.println("Warning: Some Other exception");
} finally {
System.out.println("Finally do something");
}
}
void tryMultiCatchFinally() {
try {
System.out.println("Try something");
} catch (ArithmeticException | ArrayIndexOutOfBoundsException e) {
System.out.println("Warning: Not breaking multi exceptions");
} catch (
ArithmeticException
| ArrayIndexOutOfBoundsException
| SomeOtherException e
) {
System.out.println("Warning: Breaking multi exceptions");
} finally {
System.out.println("Finally do something");
}
}
void resourceTry() {
try (Resource r = new Resource()) {
return br.readLine();
} catch (ArithmeticException | ArrayIndexOutOfBoundsException e) {
System.out.println("Warning: Not breaking multi exceptions");
}
}
void multiResourceTry() {
try (
FirstResource firstResource = new FirstResource();
SecondResource secondResource = new SecondResource()
) {
return br.readLine();
} catch (ArithmeticException | ArrayIndexOutOfBoundsException e) {
System.out.println("Warning: Not breaking multi exceptions");
}
}
void multiResourceTryWithTrailingSemi() {
try (
FirstResource firstResource = new FirstResource();
SecondResource secondResource = new SecondResource();
) {
return br.readLine();
} catch (ArithmeticException | ArrayIndexOutOfBoundsException e) {
System.out.println("Warning: Not breaking multi exceptions");
}
}
}