loading file data into arraylist...
Hi, im trying to load data from a file, created by my project, back into my project. My load function code is:
myFile.showOpenDialog(this);
path = myFile.getSelectedFile().getPath();
try
{
ObjectInputStream in = new ObjectInputStream(new FileInputStream(path));
txtMessage.append("Error Checking 1...\n");//Error checking...
myInput.cameraList = (ArrayList<String>)in.readObject();
txtMessage.append("Error Checking 2...\n");//Error checking...
txtMessage.append("Loading\n");
txtMessage.append("Loaded camera data from file... " + myInput.cameraList+"\n");
}
catch (Exception err2)
{
txtMessage.append("Error loading data... "+err2.getMessage()+"\n");
}
I am given this message: "Error loading data... null"
I have error checking as you can see, the line of code that its getting stuck on is the line just after "Error checking... 1". Im not sure whats wrong though, im not getting any complie errors...
Re: loading file data into arraylist...
The printStackTrace method is invaluable in determining the true exception and the underlying problem. I recommend using this (or a form of it) to get the full stack trace of the exception.
Re: loading file data into arraylist...
Quote:
Originally Posted by
doWhile
The printStackTrace method is invaluable in determining the true exception and the underlying problem. I recommend using this (or a form of it) to get the full stack trace of the exception.
Thanks for answer, not to sure what your talking about through sorry, im fairly new to java and programming as a whole.
Re: loading file data into arraylist...
Quote:
catch (Exception err2)
{
err2.printStackTrace();
}
Post the entirety of the result from the above in the catch statement
Re: loading file data into arraylist...
I put it into my code, it came up underlined in yellow and said "Throwable.printStackTrace(); should be removed". i tried running it anyway but it didnt display an error message.
p.s. im in doing this in netbeans, if it makes any difference...
Re: loading file data into arraylist...
Quote:
Originally Posted by
AlphaRaveNZ
I put it into my code, it came up underlined in yellow and said "Throwable.printStackTrace(); should be removed".
I have no idea what that means, and you didn't post updated code of what you did...so one can only guess. I suggest you read upon on Exceptions handling:
Lesson: Exceptions (The Java™ Tutorials > Essential Classes)