2013-06-16 06:30:01
阅读( 281 )
使用System.getProperties()方法,可以获得System.getProperty(O)的所有参数值的枚举,通过此枚举,我们就可以列举所有系统参数值
如下代码:
import java.util.Enumeration;
import java.util.Properties;
/**
*
* @author outofmemory.cn
*/
public class Main {
/**
* Lists the system properties
*/
public void listSystemProperties() {
Properties prop = System.getProperties();
Enumeration enumeration = prop.keys();
while (enumeration.hasMoreElements()) {
String key = (String) enumeration.nextElement();
System.out.println(key + " = " + prop.getProperty(key));
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
new Main().listSystemProperties();
}
}
分享给朋友:
亲~ 如果您有更好的答案 可在评论区发表您独到的见解。
您想查看更多的信息:
面试题