Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Save and load game into and from binary file

807597Apr 22 2005 — edited Apr 23 2005
hello!
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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 21 2005
Added on Apr 22 2005
2 comments
163 views