Code example for ObjectInputStream

Methods: closereadObject

0
            final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            final ObjectOutput out = new ObjectOutputStream(buffer);
            out.writeObject(l1);
            out.close();
 
            final ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
            l2 = (ObjectList) in.readObject();
            in.close();
        } 
        catch (Exception e) {
            System.out.println(e.toString());
        } 
        assertEquals(l1, l2);
 
    } 
         
    /** 
     * Tests the expand method.  This test reproduces a bug where the list was not expanded beyond 
     * the initial default size of 8.  This bug is now fixed. 
     */ 
Stop searching for code, let great code find you!  Add Codota to your java IDE