-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTryWithResource.java
More file actions
28 lines (22 loc) · 692 Bytes
/
TryWithResource.java
File metadata and controls
28 lines (22 loc) · 692 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
package io;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class TryWithResource {
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new FileReader(new File("D:\\student.csv")))) {
String row;
System.out.println("ID:\tName\tADdress");
while ((row = br.readLine()) != null) {
String[] cols = row.split(",");
System.out.println(cols[0] + "\t" + cols[1] + "\t" + cols[2]);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}