import java.nio.ByteBuffer;
public static int byteToInt(byte[] bytes){
//或//return ByteBuffer.wrap(bytes).getInt();
int number = 0;
for(int i = 0; i < 4 ; i++){
number += bytes[i] << i*8;
}
return number;
}
import java.nio.ByteBuffer;
public static long BytesToLong(byte[] buffer) {
//或//return ByteBuffer.wrap(bytes).getLong();
long values = 0;
for (int i = 0; i < 8; i++) {
values <<= 8; values|= (buffer[i] & 0xff);
}
return values;
}
参考自: