String t = xml; String utf8 = new String(t.getBytes( "UTF-8")); System.out.println(utf8); String unicode = new String(utf8.getBytes(),"UTF-8"); System.out.println(unicode); String gbk = new String(unicode.getBytes("GBK")); System.out.println(gbk);
不过这个方法是无法把中文转码的。中文转码需要用URLEncoder这个方法