有没有人回答?我考虑这样解决:
msg="31";
int msgLength = msg.length();
byte[] temp = new byte[msgLength/2]; for (int i = 0; i < msgLength; i += 2){
String temp1 = msg.substring(i,i+2);
Byte temp2 = new Byte(temp1);
temp[i/2] = temp2.byteValue();
} msg = new String(temp);这是简单的测试程序,可是最后msg得不到1;不知道为什么呀?
msg="31";
int msgLength = msg.length();
byte[] temp = new byte[msgLength/2]; for (int i = 0; i < msgLength; i += 2){
String temp1 = msg.substring(i,i+2);
Byte temp2 = new Byte(temp1);
temp[i/2] = temp2.byteValue();
} msg = new String(temp);这是简单的测试程序,可是最后msg得不到1;不知道为什么呀?
解决方案 »
- 用swing开发的日期组件是哪个
- 请教一个动态生成数组的问题。
- 用java实现生成一指定范围的随机数列
- An unexpected error has been detected by Java Runtime Environment 请问一下这是什么错误,我以前从没见过
- 高分请教一个定时更新的问题
- 如何在SWing当中显示时间
- java文本框如何绑定数据库
- 请教各位数据类型转换问题!!!
- 请问如何将jtextfield里的内容转换为数字,存放在double类型里?
- 请问c++中lpctstr对应JAVA什么类型?
- Applet与Application可以相互转换吗?
- 请问存储过程若是返回结果集记录的情况下,java如何调用?
当作另一个字符串String temp2的ascii码
看了半天,不知所云~~~
将16进制换为二进制的字串,只要:
String msg="31";String b =Integer.toBinaryString(Integer.decode("0x"+msg).intValue());
b就是你要的二进制字串了。