Topic: 求助String和byte互转

  Print this page

1.求助String和byte互转 Copy to clipboard
Posted by: beingo
Posted on: 2004-11-02 21:18

请写个代码我谢谢

2.Re:求助String和byte互转 [Re: beingo] Copy to clipboard
Posted by: babyone
Posted on: 2004-11-02 22:14

多多练习看看 java的 API文档

例子:

string sInput="111";

byte i=121;
// 注: byte型取值范围在-127-》128之间


i=Byte.parseByte(sInput);
// 这是将string 转换成 byte型


sInput=i.toString();
// 这个是将byte型转换成string


3.Re:求助String和byte互转 [Re: beingo] Copy to clipboard
Posted by: JimmyZhao
Posted on: 2004-11-03 00:13

String str = "hello";
byte ba[] = str.getBytes("ISO-8859-1");
str = new String(ba);


   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