请问各位大虾:
如何将byte[] buff=new byte[4]
转换成long型
long byte2long(byte[] buff,int offset)
{
//如何通过位移运算得到long
}
如何将byte[] buff=new byte[4]
转换成long型
long byte2long(byte[] buff,int offset)
{
//如何通过位移运算得到long
}
Byte static String toString(byte b) String->Long
Long static long parseLong(String s)
thank you,找到答案了,这样也可以
public static long bytes2Long(byte[] b, int offset)
{
return (long)
((b[offset] & 0xff) << 24)
| ((b[offset + 1] & 0xff) << 16)
| ((b[offset + 2] & 0xff) << 8)
| (b[offset + 3] & 0xff);
}