views:

157

answers:

1

I have a text file in my res/raw directory. I want to read the file line by line, but FileReader and BufferedReader fail, because of Android's security restriction. How else can I do it?

A: 

getResources().openRawResource() returns an InputStream that should be usable for line-by-line reading.

CommonsWare
Inputstream inp = this.getResources().openRawResource(R.raw.textfile);Call me stupid, but this has the methods read() [which reads a single byte], read(bytes[]) [which reads n bytes] and read(byte[], int offset, int length). No readLine()!
Vinay
@Vinay: `new BufferedReader(new InputStreamReader(this.getResources.openRawResource(R.raw.textfile)))`
CommonsWare