I have a small Java project in eclipse. The project has an src and bin folder (typical) and src is added to class path. I am running on Windows.
The following call works:
System.out.println(TestINI.class.getResource("happytest.ini"));
It prints the path of file:
file:/D:/work/baton/Touch/JTouch/bin/com/interra/tests/happytest.ini
I checked that the contents of ini file mentioned above have expected content.
But reading from the file as follows:
InputStream is = TestINI.class.getResourceAsStream("happytest.ini");
gives me an input stream which has no content. i.e. it returns a file with zero bytes.
My Eclipse is 3.6 Helios 64 bit running on Windows 7.
Google searching revealed cases where the resource path or input stream was null but that is not the case with me.
The class path entries are as follows:
<classpathentry kind="src" path="src"/>
... other class path entries for libraries like ini4j
<classpathentry kind="output" path="bin"/>
That’s exactly what Jim Garrison said – you edited the file in ‘src’ and read from ‘bin’…