我已经知道如何从本地存储中读取 xml 文件。但现在我想从 Yahoo! [链接:http ://hk.news.yahoo.com/rss/hong-kong ://hk.news.yahoo.com/rss/hong-kong ]
我使用如下代码,但它返回错误,有什么问题?!?!
String source = "http://hk.news.yahoo.com/rss/hong-kong";
URL url = new URL(source);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.connect();
InputStreamReader in = new InputStreamReader(urlConnection.getInputStream());
BufferedReader br = new BufferedReader(in);
String result = br.readLine();
Log.i(tag, "GET success: " + result);
br.close();
in.close();
错误日志是:
05-22 14:34:25.696: E/RSS(24465): java.net.ConnectException: 无法连接到 hk.news.yahoo.com/2406:2000:ac:8::c:9102(端口 80) :连接失败:EHOSTUNREACH(没有到主机的路由)
谢谢!!