How to read a directory from the runtime classpath?

后端 未结 3 1888
后悔当初
后悔当初 2021-01-04 08:51

My Java application needs to be able to find a myconfig/ directory which will be bundled inside the same JAR:

myjar.jar/
    com/
        me/
           


        
3条回答
  •  梦谈多话
    2021-01-04 09:08

    You could call ClassLoader.getResource() to find a particular file in the directory (or the directory itself, if getResource() will return directories). getResource() returns a URL pointing to the result. You could then convert this URL into whatever form the other library requires.

提交回复
热议问题