How to walk through Java class resources?

后端 未结 5 1994
栀梦
栀梦 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:29

    In general can't get a list of resources like this. Some classloaders may not even be able to support this - imagine a classloader which can fetch individual files from a web server, but the web server doesn't have to support listing the contents of a directory. For a jar file you can load the contents of the jar file explicitly, of course.

    (This question is similar, btw.)

提交回复
热议问题