- package cn.CodeSnippet;
- import java.lang.management.ManagementFactory;
- import java.lang.management.RuntimeMXBean;
- import java.util.Map;
- import java.util.Set;
- public class SystemProperties {
- public static void main(String[] args) {
- RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
- // Create a Map that holds all the properties
- Map<String, String> properties = bean.getSystemProperties();
- // Take all the keys from the Map and store them to a Set of keys
- Set<String> keys = properties.keySet();
- // For every key obtain information
- for (String key : keys) {
- String value = properties.get(key);
- System.out.println("Property["+ key +"] = " + value);
- }
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/290920136222.html
来源: http://www.codesnippet.cn/detail/290920136222.html