문제

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?

도움이 되었습니까?

해결책

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

should work. Are you sure you tried this one ?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top