Wednesday, May 9, 2012

Java列出所有系統相關資訊

下列程式碼可以列出所有系統資訊

Properties props = System.getProperties();
//使用Enumeration走訪Map物件
Enumeration enumeration = props.propertyNames();
while (enumeration.hasMoreElements()) {
    String name = (String) enumeration.nextElement();
    String value = (String) props.getProperty(name);
    System.out.println(name + ":" + value);
}

No comments:

Post a Comment