1

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

2
  • Have you set the working or starting directory in the run configuration? Did you put the file in that directory? Commented May 6, 2011 at 5:06
  • thanks a lot! that was the issue! Commented May 6, 2011 at 5:09

3 Answers 3

2

Set the working or starting directory in the run configuration, then put the file in that directory.

Sign up to request clarification or add additional context in comments.

Comments

1

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());

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.