请教中文乱码问题,
我通过
fileur = new URL(url);
URLConnection conn = fileur.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(
conn.getInputStream()));
读取一个页面,这个页面的编码是 <META http-equiv= "Content-Type " content= "text/html; charset=UTF-8 "> ,我直接while ((fileline = reader.readLine()) != null) {
System.out.println( "fileline= "+fileline);
完全是乱码,是这样鎻愪緵闈掑矝鏃ユ姤銆侀潚宀涙櫄鎶ャ?侀潚宀涙棭鎶ャ?佽?佸勾鐢熸椿鎶ャ?侀潚宀涚敾鎶ャ?佽鎶? 鍙傝?冪瓑褰撳湴鎶ュ垔鏂伴椈銆?
但是如果
fileline = new String(fileline.getBytes( "GBK "), "UTF-8 ");这样转化一下,就变成了提供青岛日报、青岛晚报???青岛早报??????年生活报???青岛画报???读?? 参???等当地报刊新闻??
请问怎样转换才能正常显示这些中文汉字阿?请指教,谢谢
------解决方案--------------------BufferedReader reader = new BufferedReader(new InputStreamReader(
conn.getInputStream(), "utf-8 "));