特别简单byte[] string 用String 的构造函数,String s = new String(byte[] bytes); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1,输出byte[]试试System.out.println(new String(aa))把String转换成byte用getChars()方法 1.数组只能一个一个的输出.2.要把 String 变为 byte 可以使用 Byte 类.system.in.read 读什么都可以 1、public void byte_out(byte[] aa) {String s=new String(aa);System.out.println(s);}2、public byte[] String_to_byte(String s) {byte[] b;java.io.StringBufferInputStream sbi=new java.io.StringBufferInputStream(s);b=new byte[sbi.available()];sbi.read(b);}catch(Exception e){System.err.print(e.toString());}return b;} sorry2、public byte[] String_to_byte(String s) {byte[] b;try {java.io.StringBufferInputStream sbi=new java.io.StringBufferInputStream(s);b=new byte[sbi.available()];sbi.read(b);}catch(Exception e){System.err.print(e.toString());}return b;} 是我说的不明白吧1 byte id[] = new byte[10]; id[0] =0x39;id[1] =0x30;id[2] =0x37;id[3] =0我想把这个id[]输出,想看到它的值,我想是9072 我想string=907然后把string转成id=byte[]不知道怎么转并输出谢谢 public class sbyte{ public byte[] String_to_byte(String s) { byte[] b; try { java.io.StringBufferInputStream sbi=new java.io.StringBufferInputStream(s); b=new byte[sbi.available()]; sbi.read(b); } catch(Exception e) {System.err.print(e.toString());} return b; } public static void main(String[] args) { new sbyte().String_to_byte(97077); // 在这里想把907077转成byte // 并输出 }}错误:sbyte.java:17: variable b might not have been initialized return b; ^Note: sbyte.java uses or overrides a deprecated API.Note: Recompile with -deprecation for details. JTextPane能把某字符串替换为图片吗? 求助:大整数乘法 类可能未被初始化 通过两个GUI窗口来实现本地简单的聊天功能 请教关于Oracle连接Connection refused的问题(在线急等) 谁分析过struts源代码? 这样新建文件为何不行? 一个关于java.util.Date类对象动态显示效果的问题 有没有Java读写CAD文件(.dwg或.dxf)的开源库呢? java送粉题,快进吧! 再问一次怎么给可执行的jar文件换个图符?有没有高手? 请问用哈希表存储数据,那我怎么获得键的名字,而不是键的值,谢谢,在线等候
把String转换成byte用getChars()方法
public void byte_out(byte[] aa) {
String s=new String(aa);
System.out.println(s);
}
2、
public byte[] String_to_byte(String s) {
byte[] b;
java.io.StringBufferInputStream sbi=new java.io.StringBufferInputStream(s);
b=new byte[sbi.available()];
sbi.read(b);
}catch(Exception e){System.err.print(e.toString());}
return b;
}
2、
public byte[] String_to_byte(String s) {
byte[] b;
try {
java.io.StringBufferInputStream sbi=new java.io.StringBufferInputStream(s);
b=new byte[sbi.available()];
sbi.read(b);
}catch(Exception e){System.err.print(e.toString());}
return b;
}
1 byte id[] = new byte[10];
id[0] =0x39;id[1] =0x30;id[2] =0x37;id[3] =0
我想把这个id[]输出,想看到它的值,我想是907
2 我想string=907然后把string转成id=byte[]不知道怎么转
并输出
谢谢
public byte[] String_to_byte(String s) {
byte[] b;
try {
java.io.StringBufferInputStream sbi=new java.io.StringBufferInputStream(s);
b=new byte[sbi.available()];
sbi.read(b);
}
catch(Exception e)
{System.err.print(e.toString());}
return b;
}
public static void main(String[] args)
{
new sbyte().String_to_byte(97077);
// 在这里想把907077转成byte
// 并输出
}}
错误:sbyte.java:17: variable b might not have been initialized
return b;
^
Note: sbyte.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.