I would like to load the contents of a text file in a String.
The text file should stay in the same folder src/my/package as the .java.
However, I can’t find the path to this file:
I have tried:
File f = new File("src/my/package/file.js");
File f = new File("file.js");
and many others but nothing worked.
What is the correct path to my file?
To open files located on the classpath, use the
Class.getResource()family of methods. They work even if the file is inside ajarfile with your classes. So something like