我在res/raw目录中保存了一些ressources,然后我想用我的自定义加载程序读取它们。
我该怎么做?
理想情况下,我会得到一个缓冲读卡器。
谢谢!
最佳答案
这是常见的方法:
InputStream rawRes = getResources().openRawResource(yourResourceName);
Reader r = new InputStreamReader(rawRes);
//no need of a buffer, it already has an [internal one][1].
您还可以将其放在assets文件夹中并按如下方式进行访问:
InputStream rawRes = context.getAssets().open("fileName.extension");
Reader r = new BufferedReader(new InputStreamReader(rawRes, "UTF8"));