When I try to read some files in my Android app they appear to not exist, here is my code:
public class ReadFiles1 {
//Static Scanner and File Objects
static Scanner s;
// Static method that returns an ArrayList
static ArrayList<String> words (String filename){
//Instantiate File with file name within parameters
File n = new File(filename);
//Instantiate Scanner s with f variable within parameters
//surround with try and catch to see whether the file was read or not
try {
s = new Scanner(n);
} catch (FileNotFoundException e) {
e.printStackTrace();
System.out.println("Problem here");
}
//Instantiate a new ArrayList of String type
ArrayList<String> theWord = new ArrayList <String>();
//while it has next ..
while(s.hasNext()){
//Initialise str with word read
String str=s.next();
//add to ArrayList
theWord.add(str);
}
//return ArrayList
return theWord;
}
I don't know what the problem is, I put the txt files in the same package as the .java files. This is the error I get when runnning this: check this link for PICTURE(https://ibb.co/cn3QCv)
W/System.err: java.io.FileNotFoundException: build/numbers.txt: open failed: ENOENT (No such file or directory)