Code example for ObjectInputStream

Methods: close, readObject

0
            ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 
            ObjectOutput out = new ObjectOutputStream(buffer); 
            out.writeObject(g1); 
            out.close(); 
 
            ObjectInput in = new ObjectInputStream( 
                    new ByteArrayInputStream(buffer.toByteArray())); 
            g2 = (HighLowItemLabelGenerator) in.readObject(); 
            in.close(); 
        } 
        catch (Exception e) { 
            e.printStackTrace(); 
        } 
        assertEquals(g1, g2); 
 
    } 
 
}