String str = "[{\"content\":\"大家一起加油\",\"publishTime\":\"2014-07-28 16:39:40\",\"title\":\"大家一起加油\"}]";
try {
byte[] bytes = str.getBytes("gbk");
for(int i = 0;i<bytes.length;i++) {
// 先把byte转成int
int v = bytes[i] & 0xFF;
// int转成16进制
String hv = Integer.toHexString(v);
System.out.print(hv+",");
}
System.out.print(bytes+",");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try {
byte[] bytes = str.getBytes("gbk");
for(int i = 0;i<bytes.length;i++) {
// 先把byte转成int
int v = bytes[i] & 0xFF;
// int转成16进制
String hv = Integer.toHexString(v);
System.out.print(hv+",");
}
System.out.print(bytes+",");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}