Code example for ObjectOutputStream

Methods: defaultWriteObjectwriteObject

0
     * 
     * @param out the output stream 
     * @throws IOException 
     */ 
    private void writeObject(ObjectOutputStream out) throws IOException {
        out.defaultWriteObject();
        out.writeObject(collection);
    } 
 
    /** 
     * Read the list in using a custom routine. 
     * 
     * @param in the input stream 
     * @throws IOException 
     * @throws ClassNotFoundException 
     */ 
    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
        in.defaultReadObject();
        collection = (Collection<E>) in.readObject();
    }