How to read several resource files with the same name from different JARs?

前端 未结 2 1536
鱼传尺愫
鱼传尺愫 2020-12-28 14:16

If there are two JAR files in the classpath, both containing a resource named \"config.properties\" in its root. Is there a way to retrieve both files similar to

2条回答
  •  鱼传尺愫
    2020-12-28 14:53

    jar files are zip files.

    Open the file using java.util.zip.ZipFile

    Then enumerate its entries looking for the properties file you want.

    When you have the entry you can get its stream with .getInputStream()

提交回复
热议问题