public static int readUnsignedIntToInt(ByteBuffer data){
  int result=0xFF & data.get();
  for (int i=1; i < 4; i++) {
    result<<=8;
    result|=0xFF & data.get();
  }
  if (result < 0) {
    throw new IllegalArgumentException("Top bit not zero: " + result);
  }
  return result;
}

public static int readUnsignedIntToInt ( ByteBuffer data ) { int result = 0xFF & data . get ( ) ; for ( int i = 1 ; i < 4 ; i ++ ) { result <<= 8 ; result |= 0xFF & data . get ( ) ; } if ( result < 0 ) { throw new IllegalArgumentException ( "Top bit not zero: " + result ) ; } return result ; }
reads an unsigned integer into an integer . this method is suitable for use when it can be assumed that the top bit will always be set to zero .
