Code example for ByteArrayOutputStream

Methods: closetoByteArray

0
    @Override 
    public byte[] encodeObject(final Object obj) throws IOException {
        ByteArrayOutputStream baos = null;
        HessianOutput output = null;
        try { 
            baos = new ByteArrayOutputStream(1024);
            output = new HessianOutput(baos);
            output.startCall();
            output.writeObject(obj);
            output.completeCall();
        } 
        catch (final IOException ex) {
            throw ex;
        } 
        finally { 
            if (output != null) {
                try { 
                    baos.close();
                } 
                catch (final IOException ex) {
                    this.logger.error("Failed to close stream.", ex);
                } 
            } 
        } 
        return baos != null ? baos.toByteArray() : null;
    } 
 
} 
Contextual code suggestions in your IDE  Get Codota for Java