Why does getResource return null

后端 未结 5 1667
感情败类
感情败类 2021-01-05 23:22

I\'m trying to access a file in my project. But getResource method returns null.

This is how my project looks like:

5条回答
  •  悲哀的现实
    2021-01-05 23:46

    Use the following code, it should work.

    YOUR_CLASS_HERE.class.getClass().getResource( "/xxx.png" );

    e.g. Signin.class.getClass().getResource( "/xxx.png" );

提交回复
热议问题