Code example for ObjectOutputStream

Methods: writeInt, writeUTF

0
        os.writeInt(table.size());
        try { 
            table.accept(new IntHashtable.Visitor() {
                public boolean visit(int key, Object value) {
                    try { 
                        os.writeInt(key);
                        os.writeUTF((String) value);
                        return true; 
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    } 
                } 
            }); 
        } catch (Exception e) {
            throw (IOException) e;
        } 
    } 
 
    private void readObject(ObjectInputStream is) throws IOException,
            ClassNotFoundException { 
        is.defaultReadObject();