I am using the following code to read a properties file:
Properties pro = new Properties();
InputStream is = Thread.currentThread().getContextClassLoader().
It looks like ClassLoader.getResourceAsStream(String name) returns null
, which then causes Properties.load
to throw NullPointerException
.
Here's an excerpt from documentation:
URL getResource(String name): Finds the resource with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.
The name of a resource is a
'/'
-separated path name that identifies the resource.Returns: A
URL
object for reading the resource, ornull
if:
- the resource could not be found, or
- the invoker doesn't have adequate privileges to get the resource.