本文介绍了如何使用通配符名称发现Java jar中的资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用通配符模式发现我的ClassLoader知道的所有xml文件。有没有办法做到这一点?

I want to discover all xml files that my ClassLoader is aware of using a wildcard pattern. Is there any way to do this?

推荐答案

这需要一点点诡计,但这里有一个相关的。首先找出罐子的URL,然后打开罐子并扫描其内容。我想你会通过查找`/META-INF/MANIFEST.MF'来发现所有罐子的URL。目录将是另一回事。

It requires a little trickery, but here's an relevant blog entry. You first figure out the URLs of the jars, then open the jar and scan its contents. I think you would discover the URLs of all jars by looking for `/META-INF/MANIFEST.MF'. Directories would be another matter.

这篇关于如何使用通配符名称发现Java jar中的资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 01:52