Code example for ObjectOutputStream

Methods: putFields, writeFields

0
        i = new Integer(1);
        e = new Exception("e");
    } 
 
    private void writeObject(ObjectOutputStream o) throws IOException {
        o.putFields().put("d", new Date());
        o.putFields().put("i", new Integer(11));
        o.writeFields();
    } 
 
    private void readObject(ObjectInputStream in) throws NotActiveException,
            IOException, ClassNotFoundException { 
        getField = in.readFields();
        d = (Date) getField.get("d", null);
        i = (Integer) getField.get("i", null);
    } 
 
    public ObjectStreamClass getObjectStreamClass() {
        return getField.getObjectStreamClass();
    } 
}