Sign in with
Sign up | Sign in
Your question

Eclipse SDK unable to find/read a .in file

Last response: in Applications
Share
March 14, 2011 12:01:47 PM

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: 
a b L Programming
March 14, 2011 2:33:22 PM

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"
m
0
l
March 15, 2011 12:01:35 PM

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. :) 
m
0
l
Related resources
a b L Programming
March 15, 2011 9:59:44 PM

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
m
0
l
a b L Programming
March 17, 2011 2:44:59 PM

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)?
m
0
l
!