Square Root of Negative One

The system cannot find the file specified

Posted in java by cheng on January 31, 2010

two hours to figure this out??

[Thanks to http://forums.java.net/jive/thread.jspa?threadID=36207&tstart=150%5D

“highscore.txt” should be in your project’s base directory, not in any of the directories that NetBeans has created for you. In your case, it should be in:

C:\Documents and Settings\Collin\My Documents\NetBeansProjects\Yahtzee

Alternatively, you can find out where your file points to in your Java code:

File file = new File("highscore.txt");
System.out.println(file.getCanonicalPath());

This should output the system-dependent, unique path to where the virtual machine believes the file is, so you can see where the discrepancy is.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: