質問

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