【问题标题】:Getting file InputStream from http从 http 获取文件 InputStream
【发布时间】:2012-02-18 23:23:11
【问题描述】:

我想从我的 ftp 主机获取一些文件,它是一个 GoDaddy 主机服务。

如果我尝试下载 .txt 文件,输入流没有问题,但如果我尝试下载 .pom 文件,则会收到 FileNotFoundException。

一段代码:

storage=(HttpURLConnection) new URL(pathToFile).openConnection();
storage.setDoInput(true);
storage.setUseCaches(false);
storage.setRequestProperty("Accept","*/*");
return storage.getInputStream();

有什么想法吗?

亚当。

【问题讨论】:

    标签: http get httpurlconnection


    【解决方案1】:

    某些网络服务器(例如 IIS6 及更高版本)如果不知道其 MIME 类型,则不会提供文件。

    【讨论】:

      猜你喜欢
      • 2018-07-12
      • 2020-09-29
      • 2017-07-24
      • 1970-01-01
      • 2017-05-05
      • 2014-01-06
      • 1970-01-01
      • 1970-01-01
      • 2016-07-17
      相关资源
      最近更新 更多