Code example for ObjectOutputStream

Methods: closeflushwriteObject

0
 
    private void doSymbolTest(Symbol s) 
        throws Exception 
    { 
        ByteArrayOutputStream os = new ByteArrayOutputStream(); 
        ObjectOutputStream oos = new ObjectOutputStream((os)); 
        oos.writeObject(s); 
        oos.flush(); 
        oos.close(); 
 
        ObjectInputStream ois = new ObjectInputStream( 
                new ByteArrayInputStream(os.toByteArray())); 
        Symbol s2 = (Symbol) ois.readObject(); 
        ois.close(); 
 
        assertTrue(s == s2); 
    } 
 
    public void testAtomic() 
        throws Exception 
Experience pair programming with AI  Get Codota for Java