我在jboss 6服务器的conf目录中有一个属性文件。
如何从我的应用程序中获取该文件中的组或所有键和值:
<attribute name="URLList">
./conf/crawler.properties
</attribute>
感谢
答案 0 :(得分:1)
这样做,但使用java.util.Properties
:
String path = System.getProperty("jboss.server.config.url") + propertiesFileName;
Properties props = new Properties();
URL url = new URL(path);
props.load(url.openStream());
Properties
类具有读取键值对的所有必要方法(它还实现了Map<Object,Object>
)。