阅读背景:

byte与int与long类型之间相互转换(好文章)

来源:互联网 
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; } import java.nio.ByteBuffer; public static int byt



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: