我正在使用一个库,我需要获得一个存储在原始文件夹中的文件路径,所以库方法会创建一个FileInputStream,但是我总是从库方法中得到一个FileNotFoundException。
因此,我创建了一个类,并尝试:
String path = "android.resource://" +context.getPackageName () + "/" + "myFileName";
InputStream fis2 = getResources().openRawResource(R.raw.myFileName);
File f = new File(path);fis2和f是正确创建的,我没有得到FileNotFoundException。
但是当我尝试:FileInputStream fis = new FileInputStream(path);时,我得到了FileNotFoundException。
发布于 2014-06-23 19:27:19
我需要一个存储在原始文件夹中的文件路径
这是不可能的,因为它不是一个文件。
库方法创建一个FileInputStream
需要对这些库方法进行调整,以便使用普通的InputStream。然后,使用您的fis2 InputStream。
https://stackoverflow.com/questions/24373714
复制相似问题