Hmm, a simple task, but how to load a properties file from a path that is not in my class path?
for example: I have a simple java file that I execute as follows: foo.jar d: /sample/dir/dir/app1.properties and in the code that I do:
public boolean InitConfig(String propePath) { prop = new Properties(); try { InputStream in = this.getClass().getClassLoader().getResourceAsStream(propePath); prop.load(in); return true; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } }
where propePath: d: /sample/dir/dir/app1.properties
and InputStream in is always null. Why is this happening?
source share