Save and load game into and from binary file
807597Apr 22 2005 — edited Apr 23 2005hello!
I'm new to java and i'm doing a game at school.
i�m doing the same game and i�m doing a "save" and "Load" game. i'm doing this to save the game:
public void jMenuJogoSalvar_actionPerformed(ActionEvent e) {
System.out.println("SAlvar o Jogo actual");
FileOutputStream out = null;
ObjectOutputStream s = null;
int valorRet = jFileChooserSalvar.showSaveDialog(this);
if (valorRet == jFileChooserSalvar.APPROVE_OPTION) {
try {
out = new FileOutputStream(jFileChooserSalvar.getSelectedFile().getAbsoluteFile());
s = new ObjectOutputStream(out);
s.writeObject(mesa);
s.flush();
}
catch (FileNotFoundException fNFExc) {
System.out.println("FileNotFound");
}
catch (IOException ioExc) {
ioExc.printStackTrace();
}
finally {
try {
if (s != null) {
s.close();
}
if (out != null) {
out.close();
}
}
catch (IOException ex) {
}
}
}
and i'm getting this error:
java.io.NotSerializableException: com.sun.java.swing.plaf.windows.WindowsFileChooserUI
i have already implemented the method Serializable into the classes that i'm trying to write and the classes they use but i still have this.
Tell me what to do .
thanks for the time.