Skip to Content
0
Former Member
Nov 30, 2006 at 06:46 AM

java.lang.NullPointerException in the code to read a properties file

1971 Views

I have written the following code to read a properties file...........

<b>

public Property(String fileName)

{

try

{

InputStream is = MyClassName.class.getClass().getClassLoader().getResourceAsStream(fileName);

prop.load(is);

is.close();

}

catch (Exception ex)

{

System.out.println("The Exception is: " + ex.getMessage());

ex.printStackTrace();

}

}

</b>

But this code is giving <b> java.lang.NullPointerException </b> at <b> prop.load(is) </b>

please help me....

regards

Brahmachaitanya