I'm working on a program (with JavaSE 1.6) that will read from text files located in the project's classpath.
The files are in a different folder than the class that's trying to access them, though, and directing my code to their location is baffling me.
The class I'm running is located in a package in the "src/test/java" folder, while the text files are separated into multiple folders (for organizational purposes) within the "src/main/resources" folder.
I'm currently trying to point to the text files using the following code, but after the line runs, 'in' receives a null value:
InputStream in = this.getClass().getResourceAsStream("/src/main/resources/<folder name here>/<file name here>.txt");
I'm not sure if I'm allowed to specify the file like this if it's in a different directory, so I'm a bit lost on how to proceed...I've searched Google and StackOverflow and found plenty of resources for reading files from the classpath but nothing about how to point the InputStream to a file outside of the class' package. Can anyone please tell me whether or not it's possible and, if so, how it can be done?