Usage of Thread.currentThread().getContextClassLoa

2019-09-30 07:58发布

问题:

In my web application, I have kept system.properties file in the web-inf/classes folder.

To Access that file's inputstream, I am using the code snippet below:

InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(SYSTEM_PROPERTIES_FILE)

Is there any other way to access that file?

回答1:

It simply means: Return the property file as InputStream from the ClassLoader the current thread of my application is running from (in loose english).