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
2010-07-10 12:56:10
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
2010-07-12 12:53:21
@Vinay: `new BufferedReader(new InputStreamReader(this.getResources.openRawResource(R.raw.textfile)))`
CommonsWare
2010-07-12 13:18:26