Scala getClass.getResource() returning null

后端 未结 4 1630
孤城傲影
孤城傲影 2021-01-01 11:10

I have this code:

val url: URL = getClass.getResource(\"com/mysite/main/test.fxml\")

and it always returns null (or Unit

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-01 11:34

    If it does not work, you can try with ClassLoader:

    ClassLoader.getSystemResource("filename").getPath
    

    The filename should be in the same directory layer

提交回复
热议问题