load file within a jar

前端 未结 3 886
名媛妹妹
名媛妹妹 2020-11-27 19:18

I need to package a configuration file within a jar. the configuration file is under the root of the jar file. However I got the following error:

Cau

3条回答
  •  孤独总比滥情好
    2020-11-27 20:00

    You should use getResourceAsStream() instead. If the file is embedded in your JAR the URI is most likely bundle:// URI

    InputStream is = this.getClass().getResourceAsStream("my.conf");
    

提交回复
热议问题