1

我正在尝试将图像文件从可能应用程序的资源复制到 sdcard 中的新文件。但我在 LogCat 中收到一个错误:

12-10 01:34:38.292: W/System.err(29307): java.io.FileNotFoundException: /es.epinanab.eic:raw/termo_k: open failed: ENOENT (No such file or directory)

这是我的代码:

File src = new File(getResources().getResourceName(R.raw.termo_k));

File dest = new File(Environment.getExternalStorageDirectory() + "/.EIC/termo_k.jpg");

try {
    InputStream in = null;
    in = new FileInputStream(src);

    OutputStream out = null;
    out = new FileOutputStream(dest);

    // Transfer bytes from in to out
    byte[] buf = new byte[1024];
    int len;

    while ((len = in.read(buf)) > 0) {
        out.write(buf, 0, len);
    }

    in.close();
    out.close();

} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
4

0 回答 0