How to walk through Java class resources?

后端 未结 5 1997
栀梦
栀梦 2020-12-13 20:35

I know we can do something like this:

Class.class.getResourceAsStream(\"/com/youcompany/yourapp/module/someresource.conf\")

to read the fil

5条回答
  •  渐次进展
    2020-12-13 21:16

    I've been looking for a way to list the contents of a jar file using the classloaders, but unfortunately this seems to be impossible. Instead what you can do is open the jar as a zip file and get the contents this way. You can use standard (here) ways to read the contents of a jar file and then use the classloader to read the contents.

提交回复
热议问题