Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

获取县天气时,调用HttpUtil.sendHttpRequest抛EOFException异常 #4

Open
captainwong opened this issue Aug 15, 2016 · 3 comments

Comments

@captainwong
Copy link

captainwong commented Aug 15, 2016

郭神救命!
第14章酷欧天气示例代码,HttpUtil.sendHttpRequest方法,其他都好着呢,就是获取某个县的天气如http://www.weather.com.cn/data/cityinfo/101020100.html , 执行到while((line = reader.readLine()) != null){这一句就抛EOFException异常,真机、模拟器都一样,怎么破啊?

@FutureWL
Copy link

FutureWL commented Nov 3, 2016

@captainwong 问题已解决,切换到HttpClient用来获取数据就会可以。可能是HttpURLConnection的BUG 成功的解决方案

@captainwong
Copy link
Author

@FutureWL 抱歉最近一直没登录github,你的仓库看不到啦。

@FutureWL
Copy link

恩,我把我之前的都删掉了。这个问题我找到的解决方案就是使用HttpClient这个类来代替书上所介绍的HttpURLConnection来进行网络访问。问题就解决了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants