-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadFile.java
More file actions
39 lines (34 loc) · 1.11 KB
/
Copy pathReadFile.java
File metadata and controls
39 lines (34 loc) · 1.11 KB
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
39
package ICP_PROJECT;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.ArrayList;
import java.io.*;
public class ReadFile {
public static ArrayList<String[]> ReadFile(String filename){
ArrayList<String[]> fileContent = new ArrayList<>();
BufferedReader reader = null;
try{
File file = new File(filename);
reader = new BufferedReader(new FileReader(file));
String contentF;
String [] fieldObjects;
String [] newObject;
while ((contentF = reader.readLine()) != null){
fieldObjects = contentF.split(",");
fileContent.add(fieldObjects);
}
}catch(FileNotFoundException fNE){
fNE.printStackTrace();
}catch(IOException ie){
ie.printStackTrace();
}
finally {
try{
if(reader != null)
reader.close();
} catch(IOException ep){
ep.printStackTrace();
}
} return fileContent;
}
}