Commit f17b5e57 authored by edmundszagars's avatar edmundszagars
Browse files

Error handling for invalid file path

parent 96a80e9e
......@@ -135,9 +135,12 @@ public class MainWindow extends Application {
dataFromCSV.setnFileLocation(filePath);
try {
list = new ArrayList<>(dataFromCSV.getDataFromCSV());
} catch (FileNotFoundException e) {
} catch (FileNotFoundException e){
new ErrorBox("File not found","");
e.printStackTrace();
}catch (NullPointerException npe){
new ErrorBox("Oops something went wrong","Error something happened");
return;
}
for (Object aList : list) {
for (Sortable sortable : sortables) {
......
......@@ -10,7 +10,7 @@ import java.util.Scanner;
public class GetDataFromCSV {
private String nFileLocation = "data.csv";
public List<ArrayList<Double>> getDataFromCSV() throws FileNotFoundException {
public List<ArrayList<Double>> getDataFromCSV() throws NullPointerException,FileNotFoundException {
List<ArrayList<Double>> nListOfValues = new ArrayList<>();
Scanner scanner = new Scanner(new BufferedReader(new FileReader(nFileLocation)));
while (scanner.hasNextLine()) {
......
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