public static int toInt(byte[] bytes, int offset, final int length) {
    if (length != SIZEOF_INT || offset + length > bytes.length) {
      throw explainWrongLengthOrOffset(bytes, offset, length, SIZEOF_INT);
    }
    int n = 0;
    for (int i = offset; i < (offset + length); i++) {
      n <<= 8;
      n ^= bytes[i] & 0xFF;
    }
    return n;
  }
public static int toInt ( byte [ ] bytes , int offset , final int length ) { if ( length != SIZEOF_INT || offset + length > bytes . length ) { throw explainWrongLengthOrOffset ( bytes , offset , length , SIZEOF_INT ) ; } 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 length of int (has to be {@link #SIZEOF_INT})
@return the int value
@throws IllegalArgumentException if length is not {@link #SIZEOF_INT} or
if there's not enough room in the array at the offset indicated.