Code example for ObjectOutputStream

Methods: writeBoolean, writeUTF

0
         * 
         * @param out 
         * @throws IOException 
         */ 
        private void writeObject(ObjectOutputStream out) throws IOException {
            if (diff == null) {
                out.writeBoolean(false);
            } else { 
                out.writeBoolean(false);
                out.writeUTF(diff);
            } 
        } 
 
        private void readObject(ObjectInputStream in) throws IOException,
                ClassNotFoundException { 
            boolean hasDiffString = in.readBoolean();
            if (hasDiffString) {
                diff = in.readUTF();
            } 
        }