views:

68

answers:

3

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!

+1  A: 

getResources().openRawResource() to get an InputStream. InputStreamReader to get a reader. InputStreamReader has built-in buffering.

CommonsWare
+1  A: 

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"));
Sephy
A: 

ok, i just figured it out:

InputStream is = app.getResources().openRawResource(R.raw.ship);
ship = OBJ.load(new BufferedReader(new InputStreamReader(is)));
clamp