Code example for ObjectOutputStream

Methods: defaultWriteObject, writeBoolean, writeLong, writeObject, writeShort, writeUTF

0
     * @param out output stream used for Object serialization. 
     * @throws IOException if any of this object's fields cannot be written to the stream. 
     * @since 1.0 
     */ 
    private void writeObject(ObjectOutputStream out) throws IOException {
        out.defaultWriteObject();
        short alteredFieldsBitMask = getAlteredFieldsBitMask();
        out.writeShort(alteredFieldsBitMask);
        if (id != null) {
            out.writeObject(id);
        } 
        if (startTimestamp != null) { 
            out.writeObject(startTimestamp);
        } 
        if (stopTimestamp != null) { 
            out.writeObject(stopTimestamp);
        } 
        if (lastAccessTime != null) { 
            out.writeObject(lastAccessTime);
        } 
        if (timeout != 0l) {
            out.writeLong(timeout);
        } 
        if (expired) {
            out.writeBoolean(expired);
        } 
        if (host != null) {
            out.writeUTF(host);
        } 
        if (!CollectionUtils.isEmpty(attributes)) {
            out.writeObject(attributes);
        } 
    } 
 
    /** 
     * Reconstitutes this object based on the specified InputStream for JDK Serialization.