I'm trying to use getResourceAsStream to load a java keystore albeit unsuccessfully. I'm not sure why it fails, but I'm loading it inside Play! 2.0 from a subfolder inside a typical folder.
Here's the folder structure and keystore location:
play root >> app >> subfolder1 >> keystore
And the location of the file I'm loading it from:
play root >> app >> subfolder1 >> scala.class
And how I am loading it inside scala.class
:
getClass().getResourceAsStream("/keystore")
Any ideas as to what's going wrong?
By prefacing the path with /
you're asking for a keystore
at the root of the package hierarchy. Try either of the following:
getClass.getResourceAsStream("/app/subfolder1/keystore")
getClass.getResourceAsStream("keystore")
See the Java documentation for more detail on how to specify resource paths.