public static void printBytes(byte[] b) {
System.out.println("\nBytes:===========");
for (int i = 0; i < b.length; i++) {
System.out.print(Integer.toHexString(b[i]) + " ");
}
}

解决方案 »

  1.   

    打印出字节就可以了撒,有的ASCII无法显示撒上面是打印出字节,还不是很标准,底下这个打印出一个字节数组的16进制表示的内容(String表示出来)
    ------------------------------------------------------------------------------
    public static String showBytes(byte[] bytes) {
    char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    'A', 'B', 'C', 'D', 'E', 'F' };
    char[] chars = new char[bytes.length * 2];
    for (int i = 0; i < bytes.length; i++) {
    int b = bytes[i];
    chars[i * 2] = hexDigits[(b >>> 4) & 0x0F];
    chars[i * 2 + 1] = hexDigits[b & 0x0F];
    }
    return new String(chars);
    }
    --------------------------------------------------------------------------
      

  2.   

    在ascii码中,一个汉字由两个字节组成,但转换后得到的是一个字节的数据
      

  3.   

    办法为:
    byte[] d=new String(c+"").getBytes("GBK");