我可以列出给定包中的资源吗? [英] Can I list the resources in a given package?
本文介绍了我可以列出给定包中的资源吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们假设我的类是从压缩的.war文件加载或加载到其他地方的,
如何才能发现给定包中的所有资源?枚举文件不会真正起作用,因为这是一个war文件。最有可能的是,这将涉及使用当前的类加载器吗?
Lets assume my classes are loaded from a compressed .war file or loaded elsewhere, how can I discover all the resources in a given package? Enumerating files will not really work, since this is a war file. Most likely this will involve using the current classloader?
是否有一个库可以做类似的事情?谷歌搜索只显示了一些带有列表文件的黑客。
Is there a library out there that does something like that? Googling revealed only some hacks with listing files.
推荐答案
不,你不能在包中列出资源,因为JVM根本就没有不知道什么资源包含在哪个包中。请参见此问题。
No, you can't list resources in a package because the JVM simply doesn't know what resources are in what package. See this question.
这篇关于我可以列出给定包中的资源吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文