-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSV.java
More file actions
31 lines (29 loc) · 793 Bytes
/
CSV.java
File metadata and controls
31 lines (29 loc) · 793 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
package utilites;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
public class CSV {
public static List<String[]> read(String file){
List<String[]> data=new LinkedList<String[]>();
String dataRow;
try{
BufferedReader br=new BufferedReader(new FileReader(file));
while((dataRow=br.readLine())!=null){
String []dataRecords=dataRow.split(" , ");
data.add(dataRecords);
}
}
catch (FileNotFoundException e) {
System.out.println("could not find file");
e.printStackTrace();
}
catch (IOException e) {
System.out.println("could not read file");
e.printStackTrace();
}
return data;
}
}