byte[] tem1 = {(byte) 0xdb,0x20,(byte) 0xdc,0x20,(byte) 0xea,0x20,0x50,0x32};
for (int v = 0; v < tem1.length; v++) {
System.out.print(tem1);//数组打印
}
System.out.println();
String str1 = "";
StringBuffer sb = new StringBuffer(str1);
for (int a = 0; a < tem1.length; a++) {
sb.append(String.valueOf(tem1[a]));
}
str1 = sb.toString();
 System.out.print(str1);String 类型打印
问一下大家 急等  在线等 
我用数组打印出来的是 
[B@1c78e57[B@1c78e57[B@1c78e57[B@1c78e57[B@1c78e57[B@1c78e57[B@1c78e57[B@1c78e57
用String类型打印出来的是
-3732-3632-22328050
我想问一下大家有什么方法 可以打印出和数组一样的乱码 
但是类型还是要String 类型 
大家帮我一下 谢谢!~!~

解决方案 »

  1.   

    没看懂楼主的意思,没有有System.out.println(byte[])方法,所以打印的是byte[]数组的toString()方法
      

  2.   

    我的意思就是 用String 类型的方法 打印出数组的乱码的方法有吗!~!~谢谢!~!~
      

  3.   

    用 String 类型 难道就打不出和 byte 打印一样的结果吗!~~
      

  4.   

    byte[] tem1 = {(byte) 0xdb,0x20,(byte) 0xdc,0x20,(byte) 0xea,0x20,0x50,0x32};
    String s = temp1.toString();
    System.out.println(s);
      

  5.   

    for (int a = 0; a < tem1.length; a++) {
                    sb.append(tem1[a].toString());
                }应该成
      

  6.   

    不是String不正确,而是你之前打印了多次System.out.print(tem1);
    public class Test
    {
    public static void main(String[] args)
    {
    byte[] tem1 = {(byte) 0xdb,0x20,(byte) 0xdc,0x20,(byte) 0xea,0x20,0x50,0x32};
    /*for (int v = 0; v < tem1.length; v++) {
    System.out.print(tem1);//数组打印
    }*/
    System.out.println(tem1);
    String s = tem1.toString();
    System.out.println(s);
    }
    }
      

  7.   

    byte[] tem1 = {(byte) 0xdb,0x20,(byte) 0xdc,0x20,(byte) 0xea,0x20,0x50,0x32};
            for (int v = 0; v < tem1.length; v++) {
                System.out.printf("0x%02x,",tem1[v]);//数组打印
            }不知道是否符合楼主要求