C的无符号数据类型int,short,byte 转为 Java对应的数据long,char,short
来源:互联网 发布:迈西背单词知乎 编辑:程序博客网 时间:2024/04/30 15:14
从网络中读取C的无符号int,short,byte字节数组,相应转换成java的long,char,short
short anUnsignedByte = 0;
char anUnsignedShort = 0;
long anUnsignedInt = 0;
int firstByte = 0;
int secondByte = 0;
int thirdByte = 0;
int fourthByte = 0;
byte buf[] = getNetData();//如:读网络字节数据
int index = 0;
firstByte = (0x000000FF & ((int)buf[index]))
index++;
anUnsignedByte = (short)firstByte;
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
- java---new和newInstance区别
- asp下连接数据库大全
- 高效的JSP分页查询
- PHP操作excel的一个例子
- X-Ways.WinHex.v14.8.SR-1.Incl.Keymaker-ZWT
- C的无符号数据类型int,short,byte 转为 Java对应的数据long,char,short
- Jmail使用方法
- rsa(毕业设计)
- VS2005的安装与部署(WEB应用程序)
- zz[java基础]jdk1.5新特性
- c/c++中结构体(struct)知识点强化,链表的学习
- KeyCode
- 什么是RIA?
- Dreamweaver中为插入的透明Flash