I cannot seem to get Java to detect my text file. It keeps giving me a FileNotFoundException() I have been able to get it to find PNG and TTF files before, but I am not sure if there is something special I need to do to get it to find text files in a resource folder.
I am using Eclipse 2018-19 (4.9.0) with OpenJDK 11.
How can I make my program manage to find and utilize this text file?
MCV Example:
public static main(String[] args) {
generateHumanName();
}
/**
* Generates a male "human-ish" name from a text file of syllables.
* @return String The male human name.
*/
private static String generateHumanName() {
try {
FileReader("/text/male_human_name_syllables.txt/");
} catch (IOException e) {
e.printStackTrace();
}
return null; // never called
}
Exception Received:
java.io.FileNotFoundException: ../res/text/male_human_name_syllables.txt (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at java.io.FileReader.<init>(FileReader.java:58)
at mcve.MCVE.generateHumanName(MCVE.java:21)
at mcve.MCVE.main(MCVE.java:12)
My File Path:
