/**
* 按网络字节序从字节数组中拿出8个字节拼装成一个long型(对应c++中的long long)数据
*
* @param from
* @param fromIndex
* @return
*/
public static long getLongLongData(byte[] from, int fromIndex) {
return (((long) from[fromIndex + 4] & 0xff) << 56)
+ (((long) from[fromIndex + 5] & 0xff) << 48)
+ (((long) from[fromIndex + 6] & 0xff) << 40)
+ (((long) from[fromIndex + 7] & 0xff) << 32)
+ (((long) from[fromIndex] & 0xff) << 24)
+ (((long) from[fromIndex + 1] & 0xff) << 16)
+ (((long) from[fromIndex + 2] & 0xff) << 8)
+ ((long) from[fromIndex + 3] & 0xff);
}
最后
以上就是英俊鸵鸟最近收集整理的关于按网络字节序从字节数组中拿出8个字节拼装成一个long型的全部内容,更多相关按网络字节序从字节数组中拿出8个字节拼装成一个long型内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复