Question

This is what my project setup looks like:

Picture of project setup. Packages and libraries '

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?

Was it helpful?

Solution

InputStream in = HTML.class.getResourceAsStream("/htmlFiles/base.html");

should work. Are you sure you tried this one ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top