public int readBytes()

in rocketmq-jms/core/src/main/java/org/apache/rocketmq/jms/domain/message/JmsBytesMessage.java [128:156]


    public int readBytes(byte[] value, int length) throws JMSException {
        if (length > value.length) {
            throw new IndexOutOfBoundsException("length must be smaller than the length of value");
        }
        if (dataAsInput == null) {
            throw new MessageNotReadableException("Message is not readable! ");
        }
        try {
            int offset = 0;
            while (offset < length) {
                int read = dataAsInput.read(value, offset, length - offset);
                if (read < 0) {
                    break;
                }
                offset += read;
            }

            if (offset == 0 && length != 0) {
                return -1;
            }
            else {
                return offset;
            }
        }
        catch (IOException e) {
            throw handleInputException(e);
        }

    }