-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExp88.java
More file actions
34 lines (31 loc) · 960 Bytes
/
Exp88.java
File metadata and controls
34 lines (31 loc) · 960 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
import java.io.*;
public class Exp88 {
public static void main(String[] args) {
BufferedReader br = null;
try {
FileReader fr = new FileReader("student.txt");
br = new BufferedReader(fr);
String line = br.readLine();
while (line != null) {
System.out.println(line);
line = br.readLine();
}
}
catch (FileNotFoundException e) {
System.out.println("File not found");
}
catch (Exception e) {
System.out.println(e.getMessage());
}
finally {
// why not working without io exception handling?
// it worked without exception handling so why specifically io exception handling?
try {
br.close();
}
catch (IOException e) {
System.out.println(e.getMessage());
}
}
}
}