Hi guys

I had serizlized objects in this way:

class A {
    private ArrayList data = new ArrayList();

    private void writeObject(ObjectOutputStream ous) throws IOException {
        out.writeObject(data);
    }

    private void readObject(ObjectInputStream ois) throws IOException,
ClassNotFoundException {
        data = out.readObject();
    }
}

And my program now works with objects of this type. I want to add new field
in the class so the class will be

class A {
    private ArrayList data = new ArrayList();
    private name = "name";

    private void writeObject(ObjectOutputStream ous) throws IOException {
        out.writeObject(data);
        out.writeObject(name);
    }

    private void readObject(ObjectInputStream ois) throws IOException,
ClassNotFoundException {
        data = out.readObject();
        // here is the problem - how to determine is this an instance of the
new version or no.
        // must I read the name or not.
    }
}

Any ideas are wellcome
Regards
Zlatko


To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm

Reply via email to