HttpURLConnection中connection.getInputStream()报异常FileNotFoundException
来源:互联网 发布:网络正规兼职写手 编辑:程序博客网 时间:2024/06/05 03:07
HttpURLConnection中connection.getInputStream()报异常FileNotFoundException,各位帮忙看看
代码如下:
String httpUrl = "http://192.168.1.102:8080/http/";
//获得的数据
String resultData = "";
URL url = null;
try
{
//构造一个URL对象
url = new URL(httpUrl);
}
catch (MalformedURLException e)
{
Log.e(DEBUG_TAG, "MalformedURLException");
}
if (url != null)
{
try {
//使用HttpURLConnection打开连接
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
urlConn.connect();
//得到读取的内容(流)
InputStreamReader in = new InputStreamReader(urlConn.getInputStream());
// 为输出创建BufferedReader
BufferedReader buffer = new BufferedReader(in);
String inputLine = null;
//使用循环来读取获得的数据
while (((inputLine = buffer.readLine()) != null))
{
//我们在每一行后面加上一个"\n"来换行
resultData += inputLine + "\n";
}
//关闭InputStreamReader
in.close();
//关闭http连接
urlConn.disconnect();
//设置显示取得的内容
if (resultData != null)
{
m_TextView.setText(resultData);
}
else
{
m_TextView.setText("读取的内容为NULL");
}
}
catch (IOException e)
{
Log.e(DEBUG_TAG, "IOException");
}
}
else
{
Log.e(DEBUG_TAG, "Url NULL");
}
输出的提示信息如下:
10-12 10:25:38.264: I/Choreographer(1728): Skipped 67 frames! The application may be doing too much work on its main thread.
10-12 10:25:39.244: I/Choreographer(1728): Skipped 86 frames! The application may be doing too much work on its main thread.
10-12 10:25:39.944: E/Http1(1728): IOException
10-12 10:25:40.414: I/Choreographer(1728): Skipped 178 frames! The application may be doing too much work on its main thread.
10-12 10:25:41.324: I/Choreographer(1728): Skipped 50 frames! The application may be doing too much work on its main thread.
0 0
- HttpURLConnection中connection.getInputStream()报异常FileNotFoundException
- HttpURLConnection中getInputStream()报异常
- HttpURLConnection.getInputStream java.io.FileNotFoundException
- connection.getInputStream()抛出java.io.FileNotFoundException
- HttpURLConnection getInputStream异常的解决
- android4.0中HttpURLConnection抛异常java.io.FileNotFoundException
- android4.0中HttpURLConnection抛异常java.io.FileNotFoundException
- HttpURLConnection抛异常java.io.FileNotFoundException
- Android4.0以上HttpURLConnection出FileNotFoundException异常解决
- android HttpURLConnection.getInputStream()问题
- connection.getInputStream 抛出IoException
- android4.0从服务器下载apk时,HttpURLConnection报java.io.FileNotFoundException: http://***
- HTTPUrlConnection 出现 FileNotFoundException 的问题
- 工作学习 问题总结 java httpurlconnection.getinputstream
- HttpURLConnection中econnreset异常之后的理解
- httpURLConnection 报错 java.net.ConnectException: localhost/127.0.0.1:8080 - Connection refused
- Java使用HttpURLConnection请求异常:java.net.SocketException: Software caused connection abort: recv failed
- 线上系统报ERR Connection timed out异常解决过程
- NGUI插件的目录结构及对于NGUI基本控件的理解(UIButton)
- maven入门
- maven基本命令
- 如何计算时间复杂度
- linux 是什么?
- HttpURLConnection中connection.getInputStream()报异常FileNotFoundException
- C++变量的声明与定义
- 12月份英语总结
- Asmack 怎么修改用户信息
- 查询 (反连接)
- #Python 初学之二编写一个小游戏#
- lvs 搭建笔记记录
- 买糖ACM
- 西行漫记