Hello forum, Im having some trouble reading a .in file for a project with the Eclipse SDK. Heres the code (Its an old competition problem thats why the names wierd).
File inFile = new File("Z:/Eclipse Projects/Problem 1 Floating Mountains/01.in");
Scanner sc = new Scanner(inFile);
Its throwing a File not Found exception even though the file is right there. I tried creating a .txt file to see if that will work and named it A01.txt and even then it just cant FIND it. I ran a line to see where it reads and its IS reading the correct location.
So, from what I can tell it cant find a file when it is in the correct place, and the correct name. I have no clue whats wrong, and really appreciate it if anyone can help out. We have wasted 2 class periods on this doing everything from changing file names to switching file locations to recreating the project folder.
I haven't done a lot of java recently so i may be wrong about this, but I think you need to use two back-slashes for every slash, like Z://Eclipse//test//01.in.
The reason for that is that you use backslashes to indicate some special characteristics, like newline (/n) and tab (/t). The two backslashes are needed so that the computer knows what to do, for example if you have a string that was "Z:/night", it needs to be able to tell if it should be: