Code example for DataOutputStream

Methods: writeBooleanwriteBytewriteShortclose

0
        try { 
            messageOutputStream = channelAssociation.acquireChannelMessageOutputStream();
        } catch (Exception e) {
            throw EjbMessages.MESSAGES.failedToOpenMessageOutputStream(e);
        } 
        dataOutputStream = new DataOutputStream(messageOutputStream);
        try { 
            // write header 
            dataOutputStream.writeByte(HEADER_TX_INVOCATION_RESPONSE);
            // write invocation id 
            dataOutputStream.writeShort(invocationId);
            // write a "bit" to indicate that this message contains the XAResource status for a "prepare" 
            // invocation 
            dataOutputStream.writeBoolean(true);
            // write the XAResource status 
            PackedInteger.writePackedInteger(dataOutputStream, xaResourceStatusCode);
        } finally { 
            channelAssociation.releaseChannelMessageOutputStream(messageOutputStream);
            dataOutputStream.close();
        } 
    } 
 
    protected void writeTxInvocationResponseMessage(final ChannelAssociation channelAssociation, final short invocationId) throws IOException {
        final DataOutputStream dataOutputStream;