遍历一下Properties,其实很简单哈:
第二种方法:
Properties p=System.getProperties();
for(Enumeration e=p.propertyNames(); e.hasMoreElements();){
String key=(String) e.nextElement();
System.out.println(key+"===>"+p.getProperty(key));
}第二种方法:
Properties p=System.getProperties();
for(Object t:p.keySet()){
System.out.println(t+"="+p.getProperty(t.toString()));
}
遍历Java系统属性
本文介绍了两种使用Java遍历系统属性的方法。第一种方法利用了枚举的方式进行遍历;第二种方法则是通过Properties对象的keySet方法来实现。这两种方法都能有效地遍历并打印出所有的系统属性。
1426

被折叠的 条评论
为什么被折叠?



