日期:2014-05-18  浏览次数:20689 次

读取url内容后,有乱码 如何解决
URL url = new URL(link);
InputStream inputStream;
try {
inputStream = url.openStream();
} catch (Exception e) {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(
"192.168.0.2", 81));
URLConnection conn = url.openConnection(proxy);
conn.connect();
inputStream = conn.getInputStream();
}

BufferedReader dis = new BufferedReader(new InputStreamReader(
inputStream, "UTF-8"));

String line;
StringBuffer xmlBuffer = new StringBuffer();
while ((line = dis.readLine()) != null) {
xmlBuffer.append(line);
}
读取link得内容后,有乱码 如何解决。。?

------解决方案--------------------
探讨
引用:
那如何既能读取UTF-8又能读取GBK的呢


如何即是JAVA,有事.NET呢? 你只能选一个。去看看浏览器里面的页面编码吧!