Commit 7252b369 authored by Olav Dagestad Eikrem's avatar Olav Dagestad Eikrem
Browse files

JavaDoc added

parent e94bb10a
......@@ -66,6 +66,7 @@
<artifactId>opencsv</artifactId>
<version>5.4</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -10,9 +10,6 @@ import java.io.*;
import java.util.Arrays;
import java.util.List;
/**
* manages reading and writing for Object Pasient to and from CSV files
*/
public class CSVManager {
String fileName;
String filePath;
......@@ -24,6 +21,12 @@ public class CSVManager {
this.patientList = FXCollections.observableArrayList();
}
public CSVManager(String fileName, String filePath){
this.fileName = fileName;
this.filePath = filePath;
this.patientList = FXCollections.observableArrayList();
}
public String getFileName() {
return fileName;
......@@ -49,6 +52,32 @@ public class CSVManager {
this.patientList = patientList;
}
public ObservableList<Pasient> readFile() throws IOException {
FileReader reader = new FileReader(this.filePath + "/" + this.fileName + ".csv");
this.patientList = FXCollections.observableArrayList();
CSVReader csvReader = new CSVReader(reader);
try{
String[] nextLine;
while ((nextLine = csvReader.readNext()) != null){
for (var e: nextLine){
System.out.println(e);
String[] patient = e.split(";");
try {
this.patientList.add(new Pasient(patient[0], patient[1], patient[2], patient[3]));
}catch (Exception e1){
}
}
}
}catch (Exception e){
e.printStackTrace();
}
reader.close();
return patientList;
}
public ObservableList<Pasient> readFileCustomPath(String path) throws IOException {
FileReader reader = new FileReader(path);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment