【问题标题】:Getting FileNotFoundException on a few URLs. Trying to download在一些 URL 上获取 FileNotFoundException。正在尝试下载
【发布时间】:2012-09-08 02:56:49
【问题描述】:

我正在为 Android 设备开发一个可下载所有内容的应用程序,但由于某些原因引发 FileNotFoundException,只有几个 URL 给我带来了问题。我打印出 URL 并将其复制到我的浏览器,它在那里工作正常,所以我不知道问题是什么。

例外:

W/System.err(14261): java.io.FileNotFoundException: 
http://feedproxy.google.com/~r/BillBurr/~5/pCkxUgHf5tY/MMPC_9-9-12.mp3

代码(减去大多数异常处理):

URL u = new URL(uri);

HttpURLConnection c = (HttpURLConnection) u.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
c.setReadTimeout(readTimeout);

int totalSize = c.getContentLength();
InputStream in = null;
try {
     in = c.getInputStream(); // Exception problem here 

     byte[] buffer = new byte[1024];
     int len1 = 0;
     ................

【问题讨论】:

标签: java android file download inputstream


【解决方案1】:

只需删除c.setDoOutput(true);。哦!

干杯harism。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-22
    • 1970-01-01
    • 2023-01-04
    • 2012-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多