import java.io.UnsupportedEncodingException;
public class UTF {
public static void main(String[] args) {
String s = "非常好";
try {
byte[] b = s.getBytes("UTF-8");
for(int i=0; i< b.length; i++){
System.out.println(Integer.toHexString(b[i]).substring(6));
}
System.out.println(new String(b, "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
输出:
e9
9d
9e
e5
b8
b8
e5
a5
bd
非常好