Eclipse SDK unable to find/read a .in file

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/");
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.

Crazzydude :pt1cable:
4 answers Last reply
More about eclipse unable find read file
  1. 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//

    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:



  2. 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. :)
  3. 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/
  4. 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)?
Ask a new question

Read More

Programming Scanners SDK Apps