Eclipse SDK unable to find/read a .in file

Crazzydude

Distinguished
Jan 21, 2011
2
0
18,510
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.

Thanks,
Crazzydude :pt1cable:
 

kyeana

Distinguished
May 21, 2008
230
0
18,860
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:

"Z:/night"

or

"Z:"
"ight"
 

Crazzydude

Distinguished
Jan 21, 2011
2
0
18,510
That doesnt seem to be changing anything, its still throwing a file not found or flat saying its an invalid domain. Thanks for the input though, any more suggestions would be a great help. :)
 

kyeana

Distinguished
May 21, 2008
230
0
18,860
Is the Z drive a mapped network drive or a local drive? If it is a mapped network drive you could try giving the full drive location instead, such as //datashare/code/eclipse projects/ect.in
 

Zenthar

Distinguished
Dec 31, 2007
250
0
18,960
Does the Exception states the name of the file it doesn't find (to make sure the name was properly inputed)?

Have you tried a path that doesn't contain spaces?

Have you tried a file within the workspace (if not already the case)?
 

TRENDING THREADS