I am trying to serialize an object with ObjectOutputStream and FileOutputStream, however an error with the class name is being shown.
JFileChooser fc = new JFileChooser();
NewClientClass AddClient = new NewClientClass(IDNumber.getText(), FirstName.getText(), LastName.getText(), Address.getText(), DateOfBirth.getText(), Profession.getText());
try {
int returnVal = fc.showSaveDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(fc.getSelectedFile().getAbsoluteFile()));
out.writeObject(AddClient); //the application crashes.
out.close();
JOptionPane.showMessageDialog(null, "Successfully Saved");
}
As you can see I am declaring a new client and getting the data from the text boxes. The data is stored correctly as I checked tru debugging, the only problem is when writing the object to file.
Any help please?
Thanks