有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

JAVA木卫一。FileNotFoundException:从安卓下载GAE blob文件时

我已经在GAE blob存储中有一个文本文件了。我试图从安卓系统访问该文件并将其保存到SD卡中

   String filename = 'HelloWorld.txt';
   String fileURL = "http://bakupand.appspot.com/download?blob-key=AMIfv95pR-81U2oXcOQ1wkj_6iwKsfRkb7Eah6LYpdN08KTeHM0Db2FUCHRHP-ijs0qVc8UFnGSeH4Tu1RlcQCn9d3gkvZK8v9FCl09aknEztvL7xEpTgS2ptL0liAxQThiyKz6SQJa_-M-9MRS8WoKzgWmZxU_ReSZ0ZSVCcubdpPoi5HFPL1w";

   try {
        File sdCard = Environment.getExternalStorageDirectory();
        File dir = new File(sdCard.getAbsolutePath() + "/doc");
        dir.mkdirs();
        URL u = new URL(fileURL);
        HttpURLConnection c = (HttpURLConnection) u.openConnection();
        c.setRequestMethod("GET");
        c.setDoOutput(true);
        c.connect();
        FileOutputStream f = new FileOutputStream(new File(dir, filename));

        InputStream in = c.getInputStream();

        byte[] buffer = new byte[1024];
        int len1 = 0;
        while ((len1 = in.read(buffer)) > 0) {
            f.write(buffer, 0, len1);
        }
        f.close();
    } catch (Exception e) {
        e.printStackTrace();
        Log.d("Downloader", e.getMessage());
    }

但是上面的代码面临IO FileNotFoundException

05-12 19:25:49.067: W/System.err(15327): java.io.FileNotFoundException: http://bakupand.appspot.com/download?blob-key=AMIfv95pR-81U2oXcOQ1wkj_6iwKsfRkb7Eah6LYpdN08KTeHM0Db2FUCHRHP-ijs0qVc8UFnGSeH4Tu1RlcQCn9d3gkvZK8v9FCl09aknEztvL7xEpTgS2ptL0liAxQThiyKz6SQJa_-M-9MRS8WoKzgWmZxU_ReSZ0ZSVCcubdpPoi5HFPL1w

有人能帮我吗?提前谢谢

注意:我可以使用相同的url从浏览器访问该文件


共 (0) 个答案