对浏览器传来的十六进制编码进行解码,以解决解析套接字中文乱码问题
public static String byteStringToString(String bytes, String encode) {
try {
String[] split = bytes.split(",");
byte[] buffer = new byte[split.length];
for (int i = 0; i < split.length; i++) {
buffer[i] = (byte) Integer.parseInt(split[i], 16);
}
return new String(buffer, encode);
} catch (UnsupportedEncodingException e) {
return null;
}
}