System.getProperties

This commit is contained in:
seahi 2024-11-10 21:32:32 +08:00
parent fe9964116e
commit 730e6a8592

View File

@ -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);
}
}
}