unsigned int的范围为0-4294967295
所以int不再适用,我们这里使用long型
程序如下
public static long readUnsignedInt(byte[] bytes) {
long b0 = ((long) (bytes[0] & 0xff));
long b1 = ((long) (bytes[1] & 0xff)) << 8;
long b2 = ((long) (bytes[2] & 0xff)) << 16;
long b3 = ((long) (bytes[3] & 0xff)) << 24;
return (long) (b0 | b1 | b2 | b3);
}