22 lines
532 B
Java
22 lines
532 B
Java
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);
|
|
}
|
|
}
|
|
}
|
|
|