STEP1: 得到资源文件 com.carel.supervisor.base.config.supervisor.properties
private static ResourceBundle resourceBundle = ResourceBundle.getBundle(
"com.carel.supervisor.base.config.supervisor");
STEP2:
resourceBundle.getString("PRODUCT_NAME");
String name = "carel.properties";
ClassLoader classLoader = Thread.currentThread()
.getContextClassLoader();
URL url = classLoader.getResource(name);
InputStream input = url.openStream();
Properties newProperties = new Properties();
newProperties.load(input);
Enumeration keys = newProperties.keys();
while (keys.hasMoreElements())
{
String key = (String) keys.nextElement();
if (!propertiesTmp.containsKey(key))
{
propertiesTmp.setProperty(key,
newProperties.getProperty(key));
added = true;
}
}
读取XML类型的配置信息
= classLoader.getResource(name);
XMLNode xmlNode = XMLNode.parse(urlService.openStream());
得到环境变量
path = System.getenv(PVPRO_HOME);