hello, i save some ressources in the res/raw directory which i then would like to read with my custom loader.
how can i do this?
ideally i would get a BufferedReader on them.
thanks!
hello, i save some ressources in the res/raw directory which i then would like to read with my custom loader.
how can i do this?
ideally i would get a BufferedReader on them.
thanks!
getResources().openRawResource()
to get an InputStream
. InputStreamReader
to get a reader. InputStreamReader
has built-in buffering.
This is the common way :
InputStream rawRes = getResources().openRawResource(yourResourceName);
Reader r = new InputStreamReader(rawRes);
//no need of a buffer, it already has an [internal one][1].
You can also put it in the assets folder and access it like that :
InputStream rawRes = context.getAssets().open("fileName.extension");
Reader r = new BufferedReader(new InputStreamReader(rawRes, "UTF8"));
ok, i just figured it out:
InputStream is = app.getResources().openRawResource(R.raw.ship);
ship = OBJ.load(new BufferedReader(new InputStreamReader(is)));