Hi folks,
Small bit of an issue trying to use ObjectInputStream and ObjectOutputStream. I'm tring to write an object of type reminder to a file so it can be opend later. not sure where im going wrong but somewhere. Not used to posting questions like this on forums but if any more info is needed reply to this and ill re post.
It keeps catching the classNotFound exception. If anyone has any ideas why this might be happening I'd greatly apppericiate it. I am having the same issue when writing and classes arnt that different so hopefully same problem blocking both classes and sort 1 sort the other.
Thanks
private class LoadListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
Container content = getContentPane();
try {
FileInputStream instream = new FileInputStream("Data.bin");
try {
ObjectInputStream in = new ObjectInputStream(instream);
reminder = (controller) in.readObject();
in.close();
} finally {
instream.close();
// switch to view GUI
content.removeAll();
content.add(viewReminder);
currentIndex=0;
}
} catch (ClassNotFoundException notfound) {
lName.setText("Illegal Information in address book file ...");
} catch (OptionalDataException data) {
lName.setText("Primitive data in address book file ...");
} catch (InvalidClassException invalid) {
lName.setText("Something is wrong with a class serialization");
} catch (IOException io) {
lName.setText("Problems accessing address book file ...");
} catch (ClassCastException cast) {
lName.setText("Illegal objects in address book file ...");
}
}
}