I am trying to read a file "words.txt" from a resource. It is a very simple, but large (2 MB), text file that I want to read line by line. I have put the file into /res/raw/words.txt, and try to open it with the following code:
try { BufferedReader in = new BufferedReader( new InputStreamReader(getResources().openRawResource(R.raw.words))); String line=in.readLine(); T.append(line); T.append("\n"); in.close(); } catch (Exception e) { T.append(e.toString()); } However, I get a java.io.IOException. This is not a "resource not found" exception, so the resource is opened correctly, but the readLine() produces the error.
I tried using the InputStream itself, with the result that read() produces -1, which stands for EOF, as if the file was empty.
Any help for me?
Till now I am still splitting up long files. So this is the best answer I can give. Anyone a better idea?