I have a words.txt file which I have placed in my res/raw folder. The words in the file are separated by space. I\'m having a hard time writing
The simplest is to use a Scanner.
Scanner s = new Scanner(getResources().openRawResource(R.raw.text_file));
try {
while (s.hasNext()) {
String word = s.next();
// ....
}
} finally {
s.close();
}
The default delimiter is whitespace (including space). If you want it to only trigger on space use s.useDelimiter(" "); after creating it.