Michael T
Michael T

Reputation: 1965

Stumped by FileNotFound exception

All I want to do is import data from a text file. The file exists at C:\temp\text.txt. However, I keep getting a file not found error. What the heck am I doing wrong???

public static void main(String[] args) throws IOException {
    String mFilename = "C:\\temp\\text.txt";
    Scanner myDataStream = new Scanner(new File(mFilename));}

Upvotes: 1

Views: 388

Answers (1)

dee-see
dee-see

Reputation: 24088

For the sake of giving this question an answer:

Googling brought up a case where someone had file extensions hidden and his file was actually text.txt.txt. Check if it's not your case.

You can display extensions in Windows 7 by going in Organize > Folder and search option > View and unchecking Hide extensions for known file types from any folder's menu.

Upvotes: 4

Related Questions