Cannot find file for FileReader
Entering a file name listings.txt to be used in this program. I am consistently getting a "file not found" error no matter where I put the file.
//This was to determine where the program is looking for files
File appBase = new File("FindMe.txt"); //current directory
String path = appBase.getAbsolutePath();
System.out.println(path);
//This is to get the file name and put it into a Filereader
//(file is to be predetermined as listings.txt)
Scanner console = new Scanner(System.in);
System.out.println("Enter the name of your listing file:");
String listingsFile = console.nextLine();
FileReader reader = new FileReader(listingsFile);
//etc etc....
// The listings.txt file IS IN the absolute directory indicated by the program. I // triplechecked.
//Error message:
Exception in thread "main" java.io.FileNotFoundException: listings.txt (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.jav a:106)
at java.io.FileInputStream.<init>(FileInputStream.jav a:66)
at java.io.FileReader.<init>(FileReader.java:41)
at exercise.Main.main(Main.java:39)
Java Result: 1