-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadCsv.java
More file actions
38 lines (32 loc) · 838 Bytes
/
ReadCsv.java
File metadata and controls
38 lines (32 loc) · 838 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
38
package io;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class ReadCsv {
public static void main(String[] args) {
BufferedReader br = null;
try {
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();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}