Eric Rizzo wrote:
And to get the text file to be on the classpath by default, store it
in the source directory along with your Java code. Eclipse
automatically copies non-Java files from the source directories to the
build output, so they are on the runtime classpath by default.
Alternatively, you can create an additional source directory just for
storing non-Java resources. That is actually the "clean" way to do it.
Hope this helps,
Eric
Eric,
Thank you very much. You have hit the point that I am not clear about.
I already have found that my text file, temp.txt was automatically
copied from the source folder (.../src/temp.txt) to the output folder (
.../bin/temp.txt). It was a shock to me. I am glad that you said it to me.
But, the problem remains:
BufferedReader inputStream = new BufferedReader(new
FileReader("temp.txt"));
tells that the file temp.txt cannot be found. I get very confused and
have spent a lot of time. I have tried Fresh, Project->Clean,....
Anything I can think of. But it still don't work. Even hard-coded the
absolute path to temp.txt, Eclipse still cannot find it. So strange!
In the end, I gave up. I moved the file temp.txt to a folder outside of
Eclipse workspace.
BufferedReader inputStream = new BufferedReader(new FileReader("absolute
path to temp.txt"));
It works fine now.
Could you help me a little more? Thank you.