public static int readAsInt(byte[] bytes, int offset, final int length) {
        if (offset + length > bytes.length) {
            throw new IllegalArgumentException("offset (" + offset + ") + length (" + length
                                               + ") exceed the" + " capacity of the array: " + bytes.length);
        }
        int n = 0;
        for (int i = offset; i < (offset + length); i++) {
            n <<= 8;
            n ^= bytes[i] & 0xFF;
        }
        return n;
    }
Converts a byte array to an int value

@param bytes  byte array
@param offset offset into array
@param length how many bytes should be considered for creating int
@return the int value
@throws IllegalArgumentException if there's not enough room in the array at the offset
                                 indicated.
stroom-bytebuffer/src/main/java/stroom/bytebuffer/hbase/Bytes.java