Issue
Here is the portion of my code that I am having trouble with:
java.io.File file = new java.io.File("src\\translate.txt");
When I compile this code in NetBeans, my code compiles and runs perfectly well, however, when I copied the .java file to my homework folder and changed the directory to my homework folder, it will compile, but it will give me the following error message:
Exception in thread "main" java.io.FileNotFoundException: .\translate.txt (The system cannot find the path specified)
And this message appears whether I put the entire directory (i.e. C://Users...etc) or I put it any other way to include using the ".\\translate.txt"
What is very strange to me is that if I change the directory in CMD to the project directory created by NetBeans and compile the .java file from there, it works through CMD if I change the code to ".\\translate.txt". This is a screenshot of NetBeans working with the code I've used.
This is a screenshot of what happens when I try to use CMD to compile and run the code.
Solution
As pointed out by @JBNizet, typing dir in CMD displays that the file extension was getting applied twice to the "translate.txt" file. Meaning the actual name of the file was "translate.txt.txt" After fixing that problem and changing the code back to its original state, it is fully functioning.
Answered By - Phillip Radke
Answer Checked By - David Marino (JavaFixing Volunteer)