Android(安卓)4.0 HttpURLConnection 下载失败问题
16lz
2022-06-18
URL u = new URL(url);HttpURLConnection c = (HttpURLConnection) u.openConnection();c.setRequestMethod("GET");c.setDoOutput(true);c.connect();(new File(FileUtils.getCachePath())).mkdirs();FileOutputStream f = new FileOutputStream(new File(file));InputStream in = c.getInputStream();
之前一直使用的这套代码下载图片.但是今天主管告诉我应用在4.0上出现问题. 查看代码后是图片下载失败的连锁反应.
在4.0上
c.getInputStream();
会报 java.io.FileNotFoundException
解决办法
// 注释掉改行. c.setDoOutput(true);
http://comments.gmane.org/gmane.comp.handhelds.android.devel/195330
更多相关文章
- Android之十三图片2D翻转
- android webview实现唤起qq临时会话
- 在Eclipse 中关联android sdk 源代码
- Android的Location功能代码
- android http通信——HttpURLConntection
- Android(安卓)Studio配置Android(安卓)annotation(注解)
- Android腾讯微薄客户端开发十四:首页menu菜单
- 操作内存卡的常用代码
- Android(安卓)Studio使用AIDL时无法找到自定义的类