1
當我使用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();
}
建議在IOException異常catch塊刪除日誌,並使用'e.printStackTrace()'來獲取詳細的錯誤信息。 – idiottiger 2012-01-10 03:13:43