1
我试图打开以下形式的HTTP连接到某个给定的URL:Android - 如何处理/打开包含非ASCII字符的URL的http连接?
http://example.com/xml.aspx?RssType=1&TypeName=中文
我想打开HTTP连接到它,得到它的inputStream,并做了一些的InputStream解析(见下面的代码片段)。但我得到的只是一个MalformedURLException。
任何人都知道这个URL有什么问题吗?是参数“?Rss ... & ...”,这是导致问题或非ASCII字符在最后有问题吗?
代码片段:
String feed = getString(R.string.feed_url);
URL url = null;
HttpURLConnection httpConn = null;
try {
url = new URL(feed);
httpConn = (HttpURLConnection) url.openConnection();
if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) { // exception here!
谢谢!而已。 – Tumer 2011-04-25 15:40:48