diff --git a/src/chapter5/Example12.java b/src/chapter5/Example12.java new file mode 100644 index 0000000..bf30d61 --- /dev/null +++ b/src/chapter5/Example12.java @@ -0,0 +1,17 @@ +package chapter5; + +import java.util.Enumeration; +import java.util.Properties; + +public class Example12 { + public static void main(String[] args) { + // 获取当前系统信息 + Properties prop = System.getProperties(); + Enumeration names = prop.propertyNames(); + while (names.hasMoreElements()) { + String key = (String) names.nextElement(); + String value = prop.getProperty(key); + System.out.println(key + "=" + value); + } + } +}