Reputation: 739
Scanner fileScanner = new Scanner(new File("C:/Users/User1/Documents/ServerSettings.dat"));
The code above cannot find the file specified. It definitely exists at the location specified.
The error given is:
java.io.FileNotFoundException: C:\Users\User1\Documents\ServerSettings.dat (The system cannot find the file specified)
Upvotes: 1
Views: 560
Reputation: 3681
If your code isn't compiling it's because you have file with a lowercase 'f' in new file
part of the code. If this is right in your code and your problem is at runtime try
System.out.println( "exists? " + new File("C:/Users/User1/Documents/ServerSettings.dat").exists() );
to see if the file really does exist Or copy and paste the file path to windows explorer.
Upvotes: 1
Reputation: 9249
Is it because you're trying to construct a new file
instead of a new File
? If so, that would likely result in a compile-time error unless you've got a custom class named file
on your classpath.
Upvotes: 2