I'm trying to read in a file, and throw each word into an arraylist, but it keeps saying it can't find the file. I've double checked (and triple, and quadruple, lol) that the file names match with correct extension and in the same directory. I feel like I'm missing something obvious. Also, I know there are other ways to read a file, but we haven't learned those yet in my class so I want to get this to work using the Scanner class.
public class FrequencyAnalysis {
private static ArrayList<String> words = new ArrayList<>();
public static void read() throws IOException {
String token;
Scanner inFile = new Scanner(new File("plaintext.txt"));
while (inFile.hasNext()){
token = inFile.next();
words.add(token);
}
}
}
public class FrequencyAnalysisTester {
public static void main(String[] Args) throws IOException {
FrequencyAnalysis.read();
}
}