io - Failing to load properties file from the same package in Java -
I have a package located at com.foo.bar
. Inside this package I have a config.properties
file, and a test.java
class. I'm just trying to load the properties file in an input stream I have tried this:
InputStream = test.class.getClassLoader () is. GetResourceAsStream ("config.properties"); System.out.println ("stream:" +);
Anything:
string path = "com.foo.bar.config.properties"; InputStream = test.class.getClassLoader () GetResourceAsStream (path); System.out.println ("stream:" +); In both cases, I get: stream: blank
in the form of value.
Try this with:
InputStream = test.class .getClassLoader () is. GetResourceAsStream ("com / foo / bar / config.properties"); Important to mention: Do not use a '/' at the beginning (this is a commortal mistake)
Comments
Post a Comment