1
2
3
//把字符串轉化為字節(jié)數(shù)組
Strings="慕課ABC";
byte[] bytes1=s.getBytes();
1
2
3
for(byte b:bytes1){
//把字節(jié)(轉換成了int)以16進制的方式顯示
System.outprintln(Integer.toHexstring(b&Oxff));//0xff--把前面24個零去掉,只留下后八位
gbk--中文占用2個字節(jié),英文占用1個字節(jié)
utf-8--中文占用3個字節(jié),英文占用1個字節(jié)
utf-16be--中文占用2個字節(jié),英文占用2個字節(jié)