Code example for ObjectOutputStream

Methods: putFieldswriteFields

    public ObjectInputStream.GetField getGetField() {
        return getField;
    private void writeObject(ObjectOutputStream o) throws IOException {
        ObjectOutputStream.PutField putField = o.putFields();
        putField.put("i", new Integer(1000));
        putField.put("d", today);
        putField.put("s", "Richard");
    private void readObject(ObjectInputStream in) throws NotActiveException,
            IOException, ClassNotFoundException { 
        getField = in.readFields();
// Primitive fields are necessary to cause the NullPointerException.  
Connect your IDE to all the code out there  Get Codota for Java