Whenever I try to load a properties file by below method. I get an error on getClass()
as-
Cannot make a static reference to the non-static method getClass() from the type Object
public static void main(String[] args) {
---
---
loadProperties(line);
}
private static void loadProperties(String line) {
Properties prop = new Properties();
InputStream in = getClass().getResourceAsStream("foo.properties");
try {
prop.load(in);
for(Object str: prop.keySet()) {
Object value = prop.getProperty((String) str);
System.out.println(str+" - "+value);
}
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Any suggestions how can I overcome this.