Code example for ByteArrayInputStream

Methods: close

0
    public Object decodeObject(final byte[] objContent) throws IOException {
        Object obj = null;
        ByteArrayInputStream bais = null;
        ObjectInputStream ois = null;
        try { 
            bais = new ByteArrayInputStream(objContent);
            ois = new ObjectInputStream(bais);
            obj = ois.readObject();
        } 
        catch (final IOException ex) {
            throw ex;
        } 
        catch (final ClassNotFoundException ex) {
            this.logger.warn("Failed to decode object.", ex);
        } 
        finally { 
            if (ois != null) {
                try { 
                    ois.close();
                    bais.close();
                } 
                catch (final IOException ex) {
                    this.logger.error("Failed to close stream.", ex);
                } 
            }