I have a properties file in the same folder as my
java class. I have tried the following code to load it, but it fails. I get an uncaught NullPointer Exception.
main.java
--------------------------------------------------------------------------------------------------
Properties properties = new Properties();
InputStream stream = null;
try {
stream = getClass().getResourceAsStream("/test.properties");
properties.load(stream);
} catch (IOException e) {
}
and my test.properties file is as follows
---------------------------------------------------------------------------------------------------
subject=Test Mail
body=Dear ${0}:\n\nThis is a
test mail.
and the code using message formatter to substitute the values is as follows :
main.java
--------------------------------------------------------------------------------------------------------
String temp=properties.getProperty("body");
java.text.MessageFormat formatter = new java.text.MessageFormat("");
formatter.applyPattern(temp);
Object[] messageArguments = {"Jim Berkley"};
String output = formatter.format(messageArguments);
for some reason, this does not work.... Any help is appreciated!!
TIA