日期:2014-05-20 浏览次数:20897 次
public static void main(String args[]) throws Exception{
String str="a";
System.out.println(str.getBytes().length); //1
System.out.println(str.getBytes("GB2312").length); //1
System.out.println(str.getBytes("utf-8").length); //1
System.out.println(str.getBytes("UTF-16BE").length); //2
System.out.println(str.getBytes("UTF-16LE").length); //2
System.out.println(str.getBytes("UTF-16").length); //4
}