以这种不同的方式阅读系统属性之间的区别是什么
RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
Object value = RuntimemxBean.getSystemProperties();
System.out.println(value);
Run Code Online (Sandbox Code Playgroud)
和
Properties systemProperties = System.getProperties();
systemProperties.list(System.out);
Run Code Online (Sandbox Code Playgroud)
RuntimeMXBean.getSystemProperties()至少在Sun JVM中,结果应该与内部调用相同System.getProperties()。
public Map<String, String> getSystemProperties() {
Properties localProperties = System.getProperties();
HashMap localHashMap = new HashMap();
Set localSet = localProperties.stringPropertyNames();
for (String str1 : localSet) {
String str2 = localProperties.getProperty(str1);
localHashMap.put(str1, str2);
}
return localHashMap;
}
Run Code Online (Sandbox Code Playgroud)
不同之处在于您可以RuntimeMXBean从远程 JVM(参见 2)获取其系统属性。
| 归档时间: |
|
| 查看次数: |
849 次 |
| 最近记录: |