java字符串乱码处理程序
public static void main(String[] args) throws UnsupportedEncodingException {
String strChineseString = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
" <books>\n" +
" <book id=\"1001\">\n" +
" <name>ÃæÉ´</name>\n" +
" <info>Çë¼ÇסÎÒ£¬ËäÈ»ÔÙ¼û±ØÐë˵</info>\n" +
" </book>\n" +
" </books>";
byte[] byteGBK = null;
byte[] byteUTF8 = null;
byte[] byteISO88591 = null;
byteGBK = strChineseString.getBytes(Charset.forName("GBK"));
byteUTF8 = strChineseString.getBytes(Charset.forName("utf-8"));
byteISO88591 = strChineseString.getBytes(Charset.forName("iso-8859-1"));
System.out.println(new String(byteGBK,"GBK"));
System.out.println(new String(byteGBK,"utf-8"));
System.out.println("**************************");
System.out.println(new String(byteUTF8,"utf-8"));
System.out.println(new String(byteUTF8,"GBK"));
System.out.println("**************************");
System.out.println(new String(byteISO88591,"utf-8"));
System.out.println(new String(byteISO88591,"GBK"));
}