Code example for ObjectInputStream

Methods: closereadObject

0
            ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 
            ObjectOutput out = new ObjectOutputStream(buffer); 
            out.writeObject(c1); 
            out.close(); 
 
            ObjectInput in = new ObjectInputStream( 
                    new ByteArrayInputStream(buffer.toByteArray())); 
            c2 = (DialCap) in.readObject(); 
            in.close(); 
        } 
        catch (Exception e) { 
            e.printStackTrace(); 
        } 
        assertEquals(c1, c2); 
 
        // check that the listener lists are independent 
        MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); 
        c1.addChangeListener(l1); 
        assertTrue(c1.hasListener(l1)); 
        assertFalse(c2.hasListener(l1)); 
Connect your IDE to all the code out there  Get Codota for Java