Hello!
I am doing homework for a college class. Any ideas on why I might be getting this error. I get them alot and am not sure if its the directory I told Eclipse to use or what. I'm confused about. I appreciate any tips too.
Exception in thread "main" java.io.FileNotFoundException: reverse.dat (No such file or directory)

Simply read the error. The file "reverse.dat" does not exist. Where is the file located relative to the calling code?

11-05-2010, 11:05 PM

pbrockway2

Code:

Scanner inFile = new Scanner(new FileReader("reverse.dat"));

You could break this step up into three parts:

* create a File instance
* create a FileReader instance using the file
* create a Scanner instance using the file reader

The reason for doing this is that the File class has methods that will enable you to get the full name of the file you are trying to use. And you can print this out with System.out.println() to see where it is your program is looking for files.

11-06-2010, 12:47 AM

erin.ctm

Simply read the error. The file "reverse.dat" does not exist. Where is the file located relative to the calling code?

This is what is confusing me. I have no clue. I have this problem with all .dat files in my code. I know I missed some critical piece but don't even know what to call it to look it up :-)

11-06-2010, 12:50 AM

Fubarable

Quote:

Originally Posted by erin.ctm

This is what is confusing me. I have no clue. I have this problem with all .dat files in my code. I know I missed some critical piece but don't even know what to call it to look it up :-)