第一种遍历:
class="java">
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()));
}
import java.util.*;
class TestSystem
{
public static void main(String[] args)
{
Map<String ,String> map = System.getenv();
//System.out.println(map);
// 遍历系统Map中system
for(String name:map.keySet()){
System.out.println(name+"->>>>>>>>"+map.get(name));
}
System.out.println(System.getenv("JAVA_HOME"));
Properties p=System.getProperties();
//遍历一下properties里面的值
for(Enumeration e=p.propertyNames(); e.hasMoreElements();){
String key=(String) e.nextElement();
System.out.println(key+"===>"+p.getProperty(key));
}
// System.out.println(p);
System.out.println(System.getProperty("os.name"));
}
}