Loading Properties from a JAR file (java 1.6)

前端 未结 2 1912
我寻月下人不归
我寻月下人不归 2021-01-17 02:22

I manually inject a properties file inside a jar. How to load properties from a jar file before java 1.7 ? I tried many workarounds and nothing worked so far.

There\

2条回答
  •  佛祖请我去吃肉
    2021-01-17 02:55

    From some class, call:

    getClass().getResourceAsStream("/path/to/props.props")
    

    Make sure that the path matches up with a classpath location.

提交回复
热议问题