【问题标题】:How to read from an online text file in Java [closed]如何从 Java 中的在线文本文件中读取 [关闭]
【发布时间】:2012-12-31 22:20:08
【问题描述】:
url = new URL("https://dl-web.dropbox.com/get/userlist.txt?w=c8bdbe4a");  
Scanner s = new Scanner(url.openStream());
q=s.next();
if(me.equals(q))
    {b=true; break;}

我收到此错误:

Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: https://dl-web.dropbox.com/get/userlist.txt?w=c8bdbe4a
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at gui.main(gui.java:48)

有人知道为什么,或者如何解决这个问题吗?我正在尝试从在线文本文件中读取。

【问题讨论】:

  • 因为您无权访问此资源...只需在浏览器中输入网址即可。

标签: java file url text runtime-error


【解决方案1】:

您似乎需要登录才能访问该文件,它不可公开访问,这就是 403 错误代码的原因

【讨论】:

    【解决方案2】:

    该资源受密码保护。您没有提供一个,因此您无法访问该文件。有关 HTTP 错误代码列表,请参阅 here

    注意:403 - 禁止。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-24
      • 2011-11-11
      • 1970-01-01
      • 1970-01-01
      • 2015-01-28
      • 1970-01-01
      相关资源
      最近更新 更多