I have code that basically reads the file and stores it in an object.
I'm having issues when trying to turn one of the String in the array into int/double etc.
I'm using a linked list to save the object.
I have tried debugging but I can't find the issue. The program runs fine and dandy until it reaches the changing of variables part. No matter what I do, what I change, or how I try to fix it the same exception occurs. And then sometimes when it works it doesn't save it.
private void readFile() {
BufferedReader in;
String line = "";
try {
in = new BufferedReader(new FileReader("Doggie.txt"));//file name
try {
line = in.readLine();
} catch (Exception e) {
line = null;
}
while (line != null) {
String[] lineArray = line.split(",");
String name = lineArray[0];
String a = lineArray[1];
String phone = lineArray[2];
String location = lineArray[3];
String p = lineArray[4];
String id = lineArray[5];
String dogName = lineArray[6];
String breed = lineArray[7];
String w = lineArray[8];
String t = lineArray[9];
String vet = lineArray[10];
int age = Integer.parseInt(a);
double payment = Double.parseDouble(p);
double weight = Double.parseDouble(w);
int times = Integer.parseInt(t);
Dog doggo = new Dog(name, phone, location, payment, id, dogName, breed, age, weight, times, vet);
dogsList.addNode(doggo);
try {
line = in.readLine();
} catch (Exception e) {
line = null;
}
}
DogsLoaded = true;
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "Error opening files, please check the information provided", "Error!", JOptionPane.ERROR_MESSAGE);
}
}