public static int bytesToInt(byte[] in,ByteOrder order){
  byte[] tmp;
  if (order == ByteOrder.LITTLE_ENDIAN) {
    tmp=in;
  }
 else {
    tmp=flipByteOrder(in);
  }
  int ret=0;
  for (int i=0; i < tmp.length; i++) {
    ret|=(tmp[i] & 0xFF) << (i * 8);
  }
  return ret;
}

public static int bytesToInt ( byte [ ] in , ByteOrder order ) { byte [ ] tmp ; if ( order == ByteOrder . LITTLE_ENDIAN ) { tmp = in ; } else { tmp = flipByteOrder ( in ) ; } int ret = 0 ; for ( int i = 0 ; i < tmp . length ; i ++ ) { ret |= ( tmp [ i ] & 0xFF ) << ( i * 8 ) ; } return ret ; }
byte array to int . assumes unsigned integer in the byte array
