But my whole point can probably be ignored if you give rid of the leading "/" for your getResourceAsStream() call. (I don't use getResourceAsStream(), so I sometimes forget the little, yet important, details.)
bad: getResourceAsStream("/more/cowbell.properties");
good: getResourceAsStream("more/cowbell.properties");
Well, it isn't quite that simple. He was using this.getClass().getResourceAsStream() which behaves differently than getClass().getClassLoader().getResourceAsStream() or Thread.currentThread().getContextClassLoader().getResourceAsStream()
Depends where the properties file exists. For example...
//loads my.properties in the same relative package location as MyClass.class InputStream is = MyClass.class.getResourceAsStream("my.properties"):
//loads my.properties in the default (root) package InputStream is = MyClass.class.getResourceAsStream("/my.properties"):
//loads my.properties from the my/package package anywhere in the current class loader
InputStream is = MyClass.class.getClassLoader().getResourceAsStream("my/package/my.properties"):
//loads my.properties from the my/package package relative to the default (root) package in the current class loader
InputStream is = MyClass.class.getClassLoader().getResourceAsStream("/my/package/my.properties"):
You can also replicate the latter two cases using the thread context class loader in order to load classes across any class loader in the JVM using...
Thread.currentThread().getContextClassLoader().getResourceAsStream("my/package/my.properties");
and
Thread.currentThread().getContextClassLoader().getResourceAsStream("/my/package/my.properties");
And then if you are in a servlet environment, you can do... getServletContext().getResourceAsStream("/WEB-INF/props/my.properties");
Jake
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]