public static boolean correctOffsetAndLengthToRead(byte[] b, int off, int len) {
        if (b == null) {
            throw new NullPointerException();
        } else if (off < 0 || len < 0 || len > b.length - off) {
            throw new IndexOutOfBoundsException();
        } else if (len == 0) {
            return false;
        }
        return true;
    }
public static boolean correctOffsetAndLengthToRead ( byte [ ] b , int off , int len ) { if ( b == null ) { throw new NullPointerException ( ) ; } else if ( off < 0 || len < 0 || len > b . length - off ) { throw new IndexOutOfBoundsException ( ) ; } else if ( len == 0 ) { return false ; } return true ; }
Security check mostly copied from {@link InputStream#read(byte[], int, int)}.
Ensures the parameter are valid.
@param b the byte array to copy from
@param off the offset to read from the array
@param len the len of the bytes to read from the array
@return <code>true</code> if there are bytes to read, otherwise <code>false</code>
@throws NullPointerException if the array is null
@throws IndexOutOfBoundsException if the index is not correct