用String 的构造函数,
String s = new String(byte[] bytes);

解决方案 »

  1.   

    1,输出byte[]试试System.out.println(new String(aa))
    把String转换成byte用getChars()方法
      

  2.   

    1.数组只能一个一个的输出.2.要把 String 变为 byte 可以使用 Byte 类.system.in.read 读什么都可以
      

  3.   

    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;
    }
      

  4.   

    sorry
    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;
    }
      

  5.   

    是我说的不明白吧
    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[]不知道怎么转
    并输出
    谢谢
      

  6.   

    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.