日期:2014-05-20  浏览次数:20897 次

中文乱码
有中文的地方类似 --> "缃戠珯绠?粙</a>锛?a"
那错了呢?请前辈指点指点...
Java code
import java.io.*;
import java.net.*;
public class TestURL {

    public static void main(String[] args) {
        try {
            URL url = new URL("http://topic.csdn.net/u/20080201/11/0bd1ec50-a68a-4215-b832-34eecb4e6a3a.html");
            try {
                BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
                String s = "";
                while ((s = br.readLine()) != null) {
                    System.out.println(s);
                }
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }

}



------解决方案--------------------
Java code
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(),"UTF-8"));

------解决方案--------------------
编码问题
------解决方案--------------------
学习