Hi all,
Sorry for the cross-post from Java - General, but I wasn't getting help
there.
I hope somebody can help me with my problem. I am trying to save an object
to disk by implementing Extenalizable. Here's the code:
class CincoModel implements Externalizable{
private Vector letterstates = new Vector(52);
private ModelProxy proxy;
...methods...
public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(letterstates);
}
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
letterstates = (Vector)in.readObject();
}
}
Here's the class that saves and loads the object:
class Cinco2 extends JFrame{
...methods...
private void saveGame(){
CincoModel m = proxy.getModel();
if (m != null){
try{
FileOutputStream ostream = new
FileOutputStream("t.tmp");
ObjectOutputStream p = new
ObjectOutputStream(ostream);
p.writeObject(m);
p.flush();
ostream.close();
} catch (IOException ioe) {
System.out.println ("Error saving file:");
System.out.println (ioe.getMessage());
}
}
}
private void loadGame(){
try{
FileInputStream instream = new
FileInputStream("t.tmp");
ObjectInputStream p = new
ObjectInputStream(instream);
CincoModel m = (CincoModel)p.readObject();
proxy.setModel(m);
instream.close();
} catch (Exception e) {
System.out.println ("Error loading file:");
System.out.println (e.getMessage());
}
}
When the loadGame() method fires, I get the following exception:
CincoModel; IllegalAccessException
Does anybody know why I'm getting this error? Thanks!
----------------<< "[EMAIL PROTECTED]" FOOTER MESSAGE >>---------------------
To leave list [EMAIL PROTECTED], please direct the one-line message
unsubscribe JAVA
to email address
[EMAIL PROTECTED]
If you have difficulties unsubscribing, please direct email to
[EMAIL PROTECTED]
York University, Toronto Canada
http://www.yorku.ca
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing