How to Load File Outside of, but Relative to, the JAR?

后端 未结 1 931
无人共我
无人共我 2021-01-18 22:43

I need to load a file outside of the JAR, but relative to it (lib/config/config.ini to be exact). I used that exact path, and it works fine as long as the work

相关标签:
1条回答
  • 2021-01-18 23:36

    Try using getClassLoader().getResource("classname") to find the URL of a class in your jar file. You'll find it's delimited with a ! between the path to the jar, and the path within a jar, which you can easily slice.

    0 讨论(0)
提交回复
热议问题