I am having some trouble understanding where to place a properties file in a java project. I have the following project structure .
src.
|
java
|
test.properties
|
a.java
Parameters.properties
I have the following code to read the properties file .
Properties prop = new Properties();
try {
InputStream in = this.getClass().getResourceAsStream("Parameters.properties");
// load a properties file
prop.load(in);
// get the property value and print it out
System.out.println(prop.getProperty("hello.world"));
} catch (IOException ex) {
ex.printStackTrace();
System.out.println("The code has failed here");
}
my properties file has the following line
hello.world=Hello World
I keep getting a null pointer error which leads me to believe it is not able to read the file because it has not got the file yet .