Code example for ObjectInputStream

Methods: closereadObject

0
        try { 
            ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 
            ObjectOutput out = new ObjectOutputStream(buffer); 
            out.writeObject(d1); 
            out.close(); 
            ObjectInput in = new ObjectInputStream( 
                    new ByteArrayInputStream(buffer.toByteArray())); 
            d2 = (SimpleHistogramDataset) in.readObject(); 
            in.close(); 
        } 
        catch (Exception e) { 
            e.printStackTrace(); 
        } 
        assertEquals(d1, d2); 
    } 
 
    private static final double EPSILON = 0.0000000001; 
 
    /** 
     * Some checks for the clearObservations() method. 
     */