C的无符号数据类型int,short,byte 转为 Java对应的数据long,char,short
来源:互联网 发布:java dwg转pdf 编辑:程序博客网 时间:2024/04/30 12:55
//从网络中读取C的无符号int,short,byte字节数组,相应转换成java的long,char,shortshort anUnsignedByte = 0;char anUnsignedShort = 0;long anUnsignedInt = 0; int firstByte = 0; int secondByte = 0; int thirdByte = 0; int fourthByte = 0;byte buf[] ="1234567890".getBytes();//如:读网络字节数据int index = 0;firstByte = (0x000000FF & ((int)buf[index]));anUnsignedByte = (short)firstByte; index++;firstByte = (0x000000FF & ((int)buf[index])) ; secondByte = (0x000000FF & ((int)buf[index+1]));index = index+2;anUnsignedShort = (char) (firstByte << 8 | secondByte); firstByte = (0x000000FF & ((int)buf[index])) ; secondByte = (0x000000FF & ((int)buf[index+1])); thirdByte = (0x000000FF & ((int)buf[index+2])); fourthByte = (0x000000FF & ((int)buf[index+3])); index = index+4;anUnsignedInt = ((long) (firstByte << 24 | secondByte << 16| thirdByte << 8 | fourthByte)) & 0xFFFFFFFFL;
- C的无符号数据类型int,short,byte 转为 Java对应的数据long,char,short
- C的无符号数据类型int,short,byte 转为 Java对应的数据long,char,short
- C的无符号数据类型int,short,byte 转为 Java对应的数据long,char,short
- C语言中各种数据类型的长度 sizeof char, short, int, long, long long
- java中byte数组与int,long,short,float,char之间的转换
- java中byte数组与int,long,short,float,char之间的转换
- Java中byte数组与short,int,char,long,float,double之间的转换
- Java中byte数组与short,int,char,long,float,double之间的转换
- Java的short,int,long
- Byte Short Int Long的长度
- java Byte和各数据类型(short,int,long,float,double)之间的转换
- java Byte和各数据类型(short,int,long,float,double)之间的转换
- java 中 byte,short,int,long的取值范围
- C、C++数据类型(int, long, short, char, long long) 的取值范围、最大最小值:climits 里的一些宏
- byte、short、char和int的转换
- java 彻底理解 byte char short int float long double
- java 彻底理解 byte char short int float long double
- java 彻底理解 byte char short int float long double
- 嵌入式LINUX环境下视频采集知识(V4L2)
- IPv4地址分类及特征 (转载qinggzha)
- 仿新浪微博底部菜单TabHost
- DAO 设计模式
- 一个双向链表的实现
- C的无符号数据类型int,short,byte 转为 Java对应的数据long,char,short
- UML感知感觉
- 七夕,染红了我的相思
- Java第三周
- 冒泡排序(Bubble Sort)
- 无法连接到服务器的错误解决方案
- 从那一天起,你就成了我的全部
- Java第四周
- 构造HTTP消息体采用HttpConnection实现文件上传