InputStream in = HTML.class.getResourceAsStream("/htmlFiles/base.html");
should work. Are you sure you tried this one ?
Frage
This is what my project setup looks like:
'
I'm trying to open the base.html file with:
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("/HttpServer/htmlFiles/base.html");
But it's always returning null. No variation of the path I use works ("/htmlFiles/base.html", "/base.html", "base.html"). I have also tried using HTML.class.getResourceAsStream() but the result is the same.
I tried to do this by making a separate source folder for the code and another for the files, but that didn't work either.
What am I doing wrong?
Lösung
InputStream in = HTML.class.getResourceAsStream("/htmlFiles/base.html");
should work. Are you sure you tried this one ?