I can't belive I have to ask for such a simple problem but it seems that I can't find a solution. I have 10 names in a txt file and I want to create a String array with that names. The names are disposed as 1 name per line so there are 10 lines in total. I have tried this code
String[] txtToString() throws IOException {
Scanner s = null;
String[] string = new String[10];
int count = 0;
try {
s = new Scanner(new BufferedReader(new FileReader(
"file:///android_res/raw/words.txt")));
while (s.hasNext()) {
count++;
string[count] = s.next();
}
} finally {
if (s != null) {
s.close();
}
}
return string;
}
But it didn't work. I've tried also putting just "words.txt" as file path but still nothing. Thanks for the help. P.s. for some unknown reason I can't import java.nio.file.Files so it must be something that don't use that import. Thanks again.