Giancarlo Giancarlo - 2 years ago 131
Java Question

open resource with relative path in java

In my java app I need to get some files and directories.

This is the program structure:

./package1/resources/repository/modules/ -> this is the dir I need to get
./package1/resources/repository/SSL-Key/cert.jks -> this is the file I need to get

loads the resourcesloader class which will load my resources (directory and file).

About the file, I tried


in order to get the real path, but this way does not work...

About the dir I have no idea how to do...


Answer Source

Supply the path relative to the classloader, not the class you're getting the loader from. For instance:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download