I have a repository which looks something like this:
/
/resources/resource1.txt
/resources/resource2.txt
/code/
/code/C/...
/code/java/pom.xml
/code/java/src/main/XYZ.java
/code/java/src/main/ABC.java
In other words, there is a maven project rooted in /code/java/
, and there are resource files located at /resources/
.
Now, I want to refer to the resource files in my code. The code will be something like the files in /code/java/src/main/XYZ.java
. How should I refer to this file?
I do not want to hard code the filepath from my local machine. For example, I do not want something like /Users/agnishom/projectX/resources/resource1.txt
. This will make it difficult for other people who clone my repository to make it work.
I would like to be able to name a file by their relative path, possibly relative to the pom.xml
file.
What is the best way to do this? Moving the resource files into the /code/java/
is not an option because they are shared by other projects which are not part of the java