日期:2014-05-20 浏览次数:20783 次
public static void main(String[] args) throws Exception{
String str = "\\x0A\\xC3\\xDC\\x0D\\x09\\x0A\\xC2\\xEB\\x02";
String pwd = getPwd(str);
System.out.println(pwd);
}
public static String getPwd(String str) throws UnsupportedEncodingException {
str = str.replaceAll("\\\\x", ""); //去除\x的标识
byte[] bs = new byte[str.length()/2 - 1]; //长度减1时为了除去结尾符02
for(int i = 0;i<bs.length;i++) {
bs[i] = (byte)Integer.parseInt(str.substring(i * 2,(i+1) * 2), 16);
}
return new String(bs, "gbk");
}