-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathUsingMultiCatch.java
More file actions
37 lines (34 loc) · 808 Bytes
/
UsingMultiCatch.java
File metadata and controls
37 lines (34 loc) · 808 Bytes
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
package exceptionsAndAssertions;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.format.DateTimeParseException;
/**
*
* @author chengfeili
* Jun 11, 2017 10:45:57 AM
*
*/
public class UsingMultiCatch {
public static void main(String[] args) {
try {
Path path = Paths.get("a.txt");
String text = new String(Files.readAllBytes(path));
LocalDate date = LocalDate.parse(text);
System.out.println(date);
} catch (DateTimeParseException | IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
/**
*
try {
throw new IOException();
} catch(IOException | RuntimeException e) {
e = new RuntimeException(); // DOES NOT COMPILE
}
*/
}
}