property, env

//如果在程序中要频繁的改变整数值,则不要用Integer,

//而应该使用int

//得到JVM的属性集

Properties pro=System.getProperties();

Set set=pro.keySet();

Iterator it=set.iterator();

while(it.hasNext()){

Object obj=it.next();

System.out.println(obj+"="+pro.get(obj));

}

System.out.println("========================");

//得到操作系统的环境变量

Map map=System.getenv();

Set set2=map.keySet();

Iterator it2=set2.iterator();

while(it2.hasNext()){

Object obj=it2.next();

System.out.println(obj+"="+map.get(obj));

}


Set set=map.keySet();

Iterator it=set.iterator();

while(it.hasNext()){

Object key=it.next();

System.out.println(key+":"+map.get(key));

}

System.out.println("======================");

Set set2=map.entrySet();

Iterator it2=set2.iterator();

while(it2.hasNext()){

Object obj=it2.next();

Map.Entry ent=(Map.Entry)obj;

System.out.println(ent.getKey()+":"+ent.getValue());

}



你可能感兴趣的:(property,env)