Topic: 请问16进制串转byte的方法

  Print this page

1.请问16进制串转byte的方法 Copy to clipboard
Posted by: lele
Posted on: 2004-10-08 13:56

比如hex:b5c4bbb0转出来的byte应该是:75 60 69 80

2.Re:请问16进制串转byte的方法 [Re: lele] Copy to clipboard
Posted by: littledeer1974
Posted on: 2004-10-08 14:04

是不是只能自己编程来实现呀(也许我没有完全理解你的意思,你可以在说明一下吗)

3.Re:请问16进制串转byte的方法 [Re: lele] Copy to clipboard
Posted by: lele
Posted on: 2004-10-08 14:58

hrhr已经解决问题

int len = data.length();
byte[] ba = new byte[len / 2];
int i = 0, j = 0, c;
while (i < len) { c = Character.digit(data.charAt(i++), 16) << 4;
c = c + Character.digit(data.charAt(i++), 16);
ba[j++] = (byte) c;
}
return ba;
}

4.Re:请问16进制串转byte的方法 [Re: lele] Copy to clipboard
Posted by: littledeer1974
Posted on: 2004-10-08 15:01

Smile

5.想问你??? [Re: lele] Copy to clipboard
Posted by: battlekiller
Posted on: 2004-10-09 17:56

length返回的是数组元素个数,但为什么要除二


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923