Android URL FileNotFoundException 错误
我正在尝试从互联网上获取文件,但遇到了一些错误。如果我在链接前面有 http:// ,它会抛出 UnkownHostException 但如果我删除 http:// ,它会给我一个协议未找到错误。
我的 url 连接代码行有
String urlS = "http://www.google.com/robots.txt";
URL url = new URL(urlS);
InputStream is = url.openStream();
任何帮助,谢谢
I am trying to get a file off the internet and im running into some errors. If I have http:// in front of the link it throws a UnkownHostException but if i remove the http:// it gives me a protocal not found error.
my url connection line of code is
String urlS = "http://www.google.com/robots.txt";
URL url = new URL(urlS);
InputStream is = url.openStream();
any help thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有点偏离主题,但是:
您可能想远离 url.openStream();由于没有超时,它可能会挂起吗?
url openstream 可能会让你挂掉
你可能想要使用 Apache HttpClient。
Kind of off topic, but:
You probably want to stay away from url.openStream(); It could just hang since no timeout with it?
url openstream might leaving you hanging
You probably want to use the Apache HttpClient.