Java中字符串转为16进制表示
String str = "鲸";
char[] chars = "0123456789ABCDEF".toCharArray();
StringBuilder builder = new StringBuilder("");
byte[] bs = str.getBytes();
int bit;
for (int i = 0; i < bs.length; i++) {
bit = (bs[i] & 0x0f0) >> 4;
builder.append(chars[bit]);
bit = bs[i] & 0x0f;
builder.append(chars[bit]);
builder.append(' ');
}
System.out.println(builder.toString().trim());