Android URL FileNotFoundException 错误

发布于 2024-11-02 03:12:36 字数 281 浏览 4 评论 0原文

我正在尝试从互联网上获取文件,但遇到了一些错误。如果我在链接前面有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

滥情哥ㄟ 2024-11-09 03:12:36

有点偏离主题,但是:

您可能想远离 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文