Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 File I/O problem.
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TokenHerbz




PostPosted: Fri Dec 14, 2012 4:28 pm   Post subject: File I/O problem.

To jump to the point, i have been able to access files several times, but today isn't my day.

I'm stumped to as why my file keeps throwing an error: java.io.FileNotFoundException: map0.txt (The system cannot find the file specified)


I have saved copies of the same name file, both in the folder, and the actual directory of my program.
I have also tried to make a direct path, which will not work either.
I have closed all of the text programs also.
I am probably just over looking something simple Sad
no compiler errors...

Some thoughts of mine would be that i am in a current directory that is to far "in" or "deep" for java? Is there a cap on the length of navigation tree java can use?

Seems really weird, but the depth of my tree is about 5 directories deep, which doesn't seem like much. I know had issues with linking JDBC stuff if it was to deep...

code:

//text file is map0.txt
File inputFile = new File("map0.txt");
FileReader fileReader = new FileReader(inputFile);  //errors this line, can't locate file to open.
BufferedReader bufferedReader = new BufferedReader(fileReader);
Sponsor
Sponsor
Sponsor
sponsor
Panphobia




PostPosted: Fri Dec 14, 2012 6:09 pm   Post subject: Re: File I/O problem.

use a relative path, and put the txt file in the actual folder of your program, dont put it next to your java file, but only next to your build and src folder, and just do
code:
BufferedReader br = new BufferedReader(new FileReader(System.getProperty("user.dir") + File.separator + "txt file name"));
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: