Reputation: 17876
I am trying to read a text file in eclipse, I have "run configurations" -> arguments set in eclipse , but it always says
Exception in thread "main" java.io.FileNotFoundException: file.txt (The system cannot find the file specified)
I have put file.txt under the same folder of myclass and in /bin folder
What else I should look into?
Thanks
Upvotes: 1
Views: 5494
Reputation: 8452
If you need to read a file from within an Eclipse plugin you are creating, you should treat at as a resource. Check this for an example: http://www.vogella.de/blog/2010/07/06/reading-resources-from-plugin/ Hope that helps.
Upvotes: 0
Reputation: 13946
Set the working or starting directory in the run configuration, then put the file in that directory.
Upvotes: 2
Reputation: 137392
Put it in the folder of the project, not in bin folder. If you want to see what is the base path of the files, you can print:
System.out.println(new File(".").getCanonicalPath());
Upvotes: 1