Code example for ObjectInputStream

Methods: close, readObject

0
            ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 
            ObjectOutput out = new ObjectOutputStream(buffer); 
            out.writeObject(s1); 
            out.close(); 
 
            ObjectInput in = new ObjectInputStream( 
                new ByteArrayInputStream(buffer.toByteArray()) 
            ); 
            s2 = (TaskSeries) in.readObject(); 
            in.close(); 
        } 
        catch (Exception e) { 
            System.out.println(e.toString()); 
        } 
        assertEquals(s1, s2); 
 
    } 
 
    /** 
     * Some checks for the getTask() method. 
     */