我正在尝试运行一个返回 XML 格式的 Web 服务,但它有时会在 3G 网络上抛出 FileNotFoundException,有时在 WIFI 网络上会成功运行
这是连接的代码:
@Override
protected ArrayList<NewsItemVO> doInBackground(Void... args) {
try {
URLConnection conn = new URL(feedUrl).openConnection();
conn.setConnectTimeout(20000);
conn.setReadTimeout(20000);
InputStream in = new BufferedInputStream(conn.getInputStream());
}
}
这是引发异常的行
InputStream in = new BufferedInputStream(conn.getInputStream());