import java.io.*;
public class CharCode1 {
public static void main(String[] args)throws IOException{
System.setProperty("file.encoding","utf-8");
// System.setProperty("file.encoding","unicode"); //为什么设计过setProperty对下面的byte[] b2=strchina.getBytes();还是没影响啊? System.getProperties().list(System.out);
String strchina="中国";
for(int i =0;i<strchina.length();i++){
byte[] b=String.valueOf(strchina.charAt(i)).getBytes("gbk");
System.out.println(b.length);
for(int ii=0;ii<b.length;ii++)
System.out.println(Integer.toHexString(b[ii]));
}
byte[] b2=strchina.getBytes();
System.out.println(b2.length);
for(int i=0;i<b2.length;i++){
System.out.println(Integer.toHexString(b2[i]));
// System.out.println(b2[i]);
}
}
}
------解决方案--------------------------------------------------------
你那是改文件的编码方式吧