nevado-jms/src/main/java/org/skyscreamer/nevado/jms/message/NevadoBytesMessage.java
/**
     * Reads a portion of the bytes message stream.
     * <P>
     * If the length of array <code>value</code> is less than the number of bytes remaining to be read from the
     * stream, the array should be filled. A subsequent call reads the next increment, and so on.
     * <P>
     * If the number of bytes remaining in the stream is less than the length of array <code>value</code>, the bytes
     * should be read into the array. The return value of the total number of bytes read will be less than the length
     * of the array, indicating that there are no more bytes left to be read from the stream. The next read of the
     * stream returns -1.
     * <p/>
     * If <code>length</code> is negative, or <code>length</code> is greater than the length of the array <code>value</code>,
     * then an <code>IndexOutOfBoundsException</code> is thrown. No bytes will be read from the stream for this
     * exception case.
     *
     * @param value  the buffer into which the data is read
     * @param length the number of bytes to read; must be less than or equal to <code>value.length</code>
     * @return the total number of bytes read into the buffer, or -1 if there is no more data because the end of the
     *         stream has been reached
     * @throws JMSException                if the JMS provider fails to read the message due to some internal error.
     * @throws MessageNotReadableException if the message is in write-only mode.
     */
Reads a portion of the bytes message stream.

If the length of array value is less than the number of bytes remaining to be read from the
stream, the array should be filled. A subsequent call reads the next increment, and so on.

If the number of bytes remaining in the stream is less than the length of array value, the bytes
should be read into the array. The return value of the total number of bytes read will be less than the length
of the array, indicating that there are no more bytes left to be read from the stream. The next read of the
stream returns -1.

If length is negative, or length is greater than the length of the array value,
then an IndexOutOfBoundsException is thrown. No bytes will be read from the stream for this
exception case.

@param value  the buffer into which the data is read
@param length the number of bytes to read; must be less than or equal to value.length
@return the total number of bytes read into the buffer, or -1 if there is no more data because the end of the
stream has been reached
@throws JMSException                if the JMS provider fails to read the message due to some internal error.
@throws MessageNotReadableException if the message is in write-only mode.
Reads a portion of the bytes message stream . If the length of array value is less than the number of bytes remaining to be read from the stream the array should be filled . A subsequent call reads the next increment and so on . If the number of bytes remaining in the stream is less than the length of array value the bytes should be read into the array . The return value of the total number of bytes read will be less than the length of the array indicating that there are no more bytes left to be read from the stream . The next read of the stream returns - 1 . If length is negative or length is greater than the length of the array value then an IndexOutOfBoundsException is thrown . No bytes will be read from the stream for this exception case . @param value the buffer into which the data is read @param length the number of bytes to read ; must be less than or equal to value . length @return the total number of bytes read into the buffer or - 1 if there is no more data because the end of the stream has been reached @throws JMSException if the JMS provider fails to read the message due to some internal error . @throws MessageNotReadableException if the message is in write - only mode .
public int readBytes(byte[] value, int length) throws JMSException {
        initializeReading();
        try {
            int n = 0;
            while (n < length) {
                int count = this.dataIn.read(value, n, length - n);
                if (count < 0) {
                    break;
                }
                n += count;
            }
            if (n == 0 && length > 0) {
                n = -1;
            }
            return n;
        }
        catch (EOFException eof) {
            JMSException jmsEx = new MessageEOFException(eof.getMessage());
            jmsEx.setLinkedException(eof);
            throw jmsEx;
        }
        catch (IOException ioe) {
            JMSException jmsEx = new JMSException("Format error occured" + ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
    }
public int readBytes ( byte [ ] value , int length ) throws JMSException { initializeReading ( ) ; try { int n = 0 ; while ( n < length ) { int count = this . dataIn . read ( value , n , length - n ) ; if ( count < 0 ) { break ; } n += count ; } if ( n == 0 && length > 0 ) { n = - 1 ; } return n ; } catch ( EOFException eof ) { JMSException jmsEx = new MessageEOFException ( eof . getMessage ( ) ) ; jmsEx . setLinkedException ( eof ) ; throw jmsEx ; } catch ( IOException ioe ) { JMSException jmsEx = new JMSException ( "Format error occured" + ioe . getMessage ( ) ) ; jmsEx . setLinkedException ( ioe ) ; throw jmsEx ; } }
Reads a portion of the bytes message stream.
Reads a portion of the bytes message stream .