按网络字节序从字节数组中拿出8个字节拼装成一个long型
来源:互联网 发布:数据统计报表 编辑:程序博客网 时间:2024/06/06 03:20
/**
* 按网络字节序从字节数组中拿出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型
- 从网络字节流中读取4个字节拼装,返回long
- 从网络字节流中读取2个字节拼装成为short
- 网络 发一个Long类型的数转化为字节数组从客户端发到服务端
- 编写简单一个程序 将一个长整型数据 写入字节数组中,在从字节数组中读出来
- 一个int和long占多少个字节
- 一个int和long占多少个字节
- Linux中网络字节序和主机字节序
- C++将8字节的long long转换成char数组
- java中,如何将一个字节数组转换成字符串?
- 将8个BOOL值放入一个字节中
- 将一个long型的数字转化为字节数组(利用IO流)
- 网络字节序与主机字节序
- 字节序和网络字节序
- 字节序和网络字节序
- 网络字节序和主机字节序
- 网络字节序与本地字节序
- 网络字节序与主机字节序
- Highcharts使用指南
- Win8应用开发介绍(五)
- 内容提供器 - Content Providers
- 隐藏tabbarviewcontroller的navigationbar和其moreNavigationController的navigationbar
- JAVA 设计模式之 策略模式
- 按网络字节序从字节数组中拿出8个字节拼装成一个long型
- linux管道
- logistic regression
- 【Unity插件】NGUI核心组件之UICamera
- postgresql集群方案hot standby初级测试(四)——xlog详细解释header
- Hdu 2222 Keywords Search
- make[1]: *** [install-pear-installer] Error 127
- php汉字转成对应的全拼
- sql2005表的基本操作