错误:网址无法打开流
问题描述:
当我使用openStream()
从Web服务解析XML,我得到的错误:错误:网址无法打开流
Can not open stream
我检查的URL,它仍然工作。
URL url = new URL("http://uitbookshop.php0h.com/PHPService/findbyname.php?name=thu");
Log.d("search", "getXML::url "+url.toString());
InputStream iS;
try {
iS = url.openStream();
doc=db.parse(new InputSource(new InputStreamReader(iS, Charset.forName("utf-8"))));
} catch (IOException e) {
Log.e("search", "Can not open stream");
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
答
你有适当的权限? 请确保您有以下权限添加到清单
android.permission.INTERNET
+0
谢谢你,它的工作原理 – 2012-01-10 03:17:37
建议在IOException异常catch块删除日志,并使用'e.printStackTrace()'来获取详细的错误信息。 – idiottiger 2012-01-10 03:13:43