It's thus in the classpath. You can just use ClassLoader#getResourceAsStream()
to get an InputStream
out of it. Assuming that src
is the classpath root and that main/resources
is the package:
InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream("main/resources/foo.properties");
Properties properties = new Properties();
properties.load(input);
// ...
Alternatively, if it's supposed to be specific to the webapp and thus isn't supposed to be overrideable by a file on the same path elsewhere in the classpath which has a higher classloading precedence (e.g. in appserver's lib or the JRE's lib), then use ExternalContext#getResourceAsStream()
instead.
InputStream input = FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream("main/resources/foo.properties");
Properties properties = new Properties();
properties.load(input);
// ...
As to the #{resource}
syntax, this is indeed specifically for CSS/JS/image resources placed in /resources
folder of public web content. See also How to reference CSS / JS / image resource in Facelets template?