测试如下:try{
byte[] arg1 = new byte[]{(byte)96, (byte)0, (byte)3, (byte)63, (byte)63, (byte)-36,
(byte)-9, (byte)63, (byte)63,(byte)63, (byte)63, (byte)63, (byte)63,(byte)-49, (byte)-2,
(byte)0, (byte)0, (byte)0, (byte)0, (byte)0,(byte) 0, (byte)0}; byte[] arg2 = new byte[]{(byte)96, (byte)0, (byte)3, (byte)-32, (byte)-1, (byte)-36,
(byte)-9, (byte)-1, (byte)-1,(byte)-1, (byte)-1, (byte)-2, (byte)-1,(byte) (byte)-49, (byte)-2,
(byte)0, (byte)0,(byte)0, (byte)0, (byte)0,(byte) 0, (byte)0};
System.out.println("arg1 =:" + new String(arg1,"GB2312"));
System.out.println("arg2 =:" + new String(arg1,"GB2312"));
String arg3 = new String(arg1,"GB2312");
byte[] a1 = a.getBytes("GB2312");
System.out.println("输入出的byte:");
for (int i = 0; i < a1.length; i++) {
System.out.print(a1[i]+",");
}
} catch (Exception e) {
e.printStackTrace();
} 最终输出的结果如下: 请问为什么会出现这种情况??
byte[] arg1 = new byte[]{(byte)96, (byte)0, (byte)3, (byte)63, (byte)63, (byte)-36,
(byte)-9, (byte)63, (byte)63,(byte)63, (byte)63, (byte)63, (byte)63,(byte)-49, (byte)-2,
(byte)0, (byte)0, (byte)0, (byte)0, (byte)0,(byte) 0, (byte)0}; byte[] arg2 = new byte[]{(byte)96, (byte)0, (byte)3, (byte)-32, (byte)-1, (byte)-36,
(byte)-9, (byte)-1, (byte)-1,(byte)-1, (byte)-1, (byte)-2, (byte)-1,(byte) (byte)-49, (byte)-2,
(byte)0, (byte)0,(byte)0, (byte)0, (byte)0,(byte) 0, (byte)0};
System.out.println("arg1 =:" + new String(arg1,"GB2312"));
System.out.println("arg2 =:" + new String(arg1,"GB2312"));
String arg3 = new String(arg1,"GB2312");
byte[] a1 = a.getBytes("GB2312");
System.out.println("输入出的byte:");
for (int i = 0; i < a1.length; i++) {
System.out.print(a1[i]+",");
}
} catch (Exception e) {
e.printStackTrace();
} 最终输出的结果如下: 请问为什么会出现这种情况??
解决方案 »
- java手机应用
- 多个客户端每20秒读取一次socket,然后显示在页面上,多线程如何设计
- 动态二维数组初始化问题
- JFrame里动态显示其它JFrame或JPanel该如何实现?
- js里setTimeout方法做延时操作,结果发现里面的方法执行了3遍
- 0到10之间数自动增减,关于多线程的问题??
- 各位谁有比较好的短信二次开发控件,或者有没有金笛的java版,急需,100分相送,另加500分
- 有关swing控件的问题,请各位高手帮忙
- 为啥找不到符号?我是新手,呵呵呵
- 征求“java编程技巧10001例”完全版!
- 小弟再次求解~请各位大虾帮帮忙~!这是一作业题
- 关于接口的问题,有些不明白,请教了
byte[] a1 = str.getBytes("GB2312");
System.out.println("输入出的byte:");
for (int i = 0; i < a1.length; i++) {
System.out.print(a1[i]+",");
}
arg2 = new byte[]{(byte)-60, (byte)-29, (byte)-70, (byte)-61};
System.out.println("arg2 =:" + new String(arg2,"GB2312"));应该是一样的。
“arg1”和“arg2”是两个不同的byte[]数组,但在转换成String 之后,输出的都是一样的,而且arg1转换成String,然后再又转换成byte[],所得的结果恰恰是arg2 byte[]!
byte[] a1 = arg3.getBytes("GB2312");
不好意思的,在发帖编辑格式的时候,弄丢了的!