在java中,分出了这样的字符串变量的值:http://www.wangjiu.com/product/shoppingmall-product_type-1-country-\xC6\xE4\xCB\xFB\xB9\xFA\xBC\xD2-categoryname-\xB8\xC9\xB0\xD7\xC6\xCF\xCC\xD1\xBE\xC6-variety-\xC6\xE4\xCB\xFB\xBA\xEC\xC6\xB7\xD6\xD6\xBB\xEC\xBA\xCF-brand-\xCA\xC0\xBD\xE7\xC3\xFB\xC5\xC6.html有师兄能帮解吗?有这样大量的数据,求师兄给出在java中解开这样数据的代码。不胜感激!!!!!!
利用BASE64Decoder解码
String base64 = "http://www.wangjiu.com/product/shoppingmall-product_type-1-country-\\xC6\\xE4\\xCB\\xFB\\xB9\\xFA\\xBC\\xD2-categoryname-\\xB8\\xC9\\xB0\\xD7\\xC6\\xCF\\xCC\\xD1\\xBE\\xC6-variety-\\xC6\\xE4\\xCB\\xFB\\xBA\\xEC\\xC6\\xB7\\xD6\\xD6\\xBB\\xEC\\xBA\\xCF-brand-\\xCA\\xC0\\xBD\\xE7\\xC3\\xFB\\xC5\\xC6.html"; BASE64Decoder decode = new BASE64Decoder(); byte [] b = decode.decodeBuffer(base64); System.out.println( new String(b));
Pattern pattern = Pattern.compile("(?i)\\\\x([0-9a-f]{2})");
Matcher matcher = pattern.matcher(str);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while (matcher.find()) {
baos.write(Integer.parseInt(matcher.group(1), 16));
}
byte[] bytes = baos.toByteArray();
String decoded = new String(bytes, "GB2312");
System.out.println(decoded);干白葡萄酒
byte[] bytes = baos.toByteArray();
String decoded = new String(bytes, System.getProperty("file.encoding"));