posted 2 weeks ago
What getResource() and getResourceAsStream() are good for is when you want to access files that are deployed as part of or next to your code - usually as part of a .jar or .war file. They look for resources using the same classpath that your classes use - see the javadoc for more details. But if you want to access a file that has nothing to do with your deployed code, but has some other, unrelated path... for that, use something like Files.readString(path) or Files.lines(path).
So as Carey said, we need to know more about where your file is stored.