public static void main(String[] args){ String a="哈哈"; try { byte[] aa = a.getBytes("GB2312"); byte[] ab = a.getBytes("UTF-8"); for (int i = 0; i < aa.length; i++) { System.out.print(aa[i]); } System.out.println();
for (int i = 0; i < ab.length; i++) { System.out.print(ab[i]); } System.out.println();
大家都对编码比较头疼。下面一个例子,大家仔细看看。自己试一下。 public class test { public static void main(String[] args){ String a="哈哈"; try { byte[] aa = a.getBytes("GB2312"); byte[] ab = a.getBytes("UTF