Code example for XMLDecoder

Methods: closereadObject

0
            afe.initCause(exceptions.getFirst());
            throw afe;
        } 
 
        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
        XMLDecoder dec = new XMLDecoder(in, null, listener);
        Project p2 = (Project) dec.readObject();
        assertNotNull(p2);
        dec.close();
 
        // verify that the read didn't fail 
        if (!exceptions.isEmpty()) {
            AssertionFailedError afe = new AssertionFailedError(
                    "Got " + exceptions.size() + " exception(s)");
            // Can only chain one of the exceptions. Take the first one. 
            afe.initCause(exceptions.getFirst());
            throw afe;
        } 
    } 
}