使用jboss 6属性服务检索属性值

时间:2013-05-16 18:14:33

标签: java jboss jboss6.x

我在jboss 6服务器的conf目录中有一个属性文件。

如何从我的应用程序中获取该文件中的组或所有键和值:

<attribute name="URLList">
  ./conf/crawler.properties
</attribute>

感谢

1 个答案:

答案 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>)。