I want to read all of the files from within my package without using my entire file path. For example I can use something like this to get all of the files in a dir.
new File("/Users/me/Documents/workspace/testing/src/main/java/resources/").listFiles()
When I have a package in intellij that looks like this:
main
- java
--com.testFile
--resources
I read this: Read file from a folder inside the project directory. However I want to be able to do this without specifying the the whole path.
For example it is explained here: How to read a file (e.g txt file) from another java package withouth specifying the absolute path?
I thought I could do something like
"src/main/java/resources" but every combination I try fails when plugged in to:
new File("/Users/me/Documents/workspace/testing/src/main/java/resources/").listFiles()
I could have sworn I've done this before like this? Am I making a silly mistake?
As of right now it can't locate the file. It's being run from a file in a file in java -> com.thisproject/app
For example I'm seeing:
File folder = new File("src/");
File[] listOfFiles = folder.listFiles();
have listOfFiles be null.