From 730e6a85927a6febd59f432ae955560b2ca1c07f Mon Sep 17 00:00:00 2001 From: seahi Date: Sun, 10 Nov 2024 21:32:32 +0800 Subject: [PATCH] System.getProperties --- src/chapter5/Example12.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/chapter5/Example12.java 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); + } + } +}