HTTPUrlConnection 出现 FileNotFoundException 的问题
来源:互联网 发布:零基础网络运维工程师 编辑:程序博客网 时间:2024/06/10 21:14
URL url = new URL(strUrl);HttpURLConnection conn = (HttpURLConnection) url.openConnection();conn.getInputStream()
HTTPUrlConnection 在 getInputStream出现 FileNotFoundException 的问题,可能有两种情况:
1. URL中带有中文可能导致这个问题。具体分析待补充。使用 URLEncoder.encode(..)解决。
参看这里 http://blog.csdn.net/berber78/article/details/7245872
2. URL确定OK的话,还是出现FileNotFoundException ,可以看看是否是如下情况:
a FileNotFoundException
also comes when you get an error message from the server and then try to access getInputStream()
. If the Response code is a 400 or above, any call to getInputStream()
will throw this error. In this case, you should check getErrorStream()
instead. See my answer here.
if ( conn.getResponseCode() >= 400) { conn.getErrorStream();} else { conn.getInputStream();}
参看这里:
http://stackoverflow.com/questions/9472425/filenotfoundexception-on-android-version-2-3/18151461#18151461
0 0
- HTTPUrlConnection 出现 FileNotFoundException 的问题
- FileNotFoundException问题的解决
- 关于HttpURLConnection遇到ava.io.FileNotFoundException的解决方法
- java 出现FileNotFoundException异常的具体情况排除
- 使用HttpURLConnection下载文件时出现 java.io.FileNotFoundException彻底解决办法
- 使用HttpURLConnection下载文件时出现 java.io.FileNotFoundException彻底解决办法
- HttpURLConnection.getInputStream java.io.FileNotFoundException
- 关于IO流在复制文件时出现java.io.FileNotFoundException: D:\xxx (拒绝访问。) 拒绝访问的问题
- HttpURLConnection 下载出现302 重定向问题
- 【文件】FileOutputStream 出现 FileNotFoundException
- HttpURLConnection抛异常java.io.FileNotFoundException
- HttpURLConnection中connection.getInputStream()报异常FileNotFoundException
- 【总结】关于fileoutputstream应用中的FileNotFoundException问题的解决办法
- 使用Ant编译出现如下问题 java.io.FileNotFoundException: bin\classes.dex
- [Android]解决HttpURLConnection上传大文件时出现OOM问题
- android4.0中HttpURLConnection抛异常java.io.FileNotFoundException
- Android4.0以上HttpURLConnection出FileNotFoundException异常解决
- android4.0中HttpURLConnection抛异常java.io.FileNotFoundException
- 秀发润泽一冬,护发首当其冲
- 关于spring mvc拦截器拦截js文件等导致无法正常使用问题的解决
- PullToRefresh(下拉刷新)源码浅析
- log4j的简单介绍和应用以及与commons-logging的区别
- JMS教程(一)
- HTTPUrlConnection 出现 FileNotFoundException 的问题
- Java中static作用详解
- Java验证是否是身份证号
- js Math 对象方法
- abap报表中(ALV或者普通屏幕的定制控制中)如何让列可以使用求和按钮
- QT环境下出现undefined refence to symbol...
- Redis Cluster 3.0搭建与使用
- try throw catch
- 钉钉的功能介绍