String str ="一";
byte temp [] = str.getBytes();
得到的byte值分别为:-46 -69
char str="一";
ChartoByteArray(str);
//字符转换为byte数组
public void ChartoByteArray(int number) {
int temp = number;
byte[] by = new byte[2];
for(int i=by.length-1;i>=0;i--) {
by[i] = new Integer(temp&0xff).byteValue();
temp = temp>>8;
}
}
得到的byte值为 0,78
为什么值两组值不一样????
byte temp [] = str.getBytes();
得到的byte值分别为:-46 -69
char str="一";
ChartoByteArray(str);
//字符转换为byte数组
public void ChartoByteArray(int number) {
int temp = number;
byte[] by = new byte[2];
for(int i=by.length-1;i>=0;i--) {
by[i] = new Integer(temp&0xff).byteValue();
temp = temp>>8;
}
}
得到的byte值为 0,78
为什么值两组值不一样????
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货