Java常用实体类

System类

  访问系统属性 - 遍历

 1 package org.zln.usefulclass.system;
 2 
 3 import java.util.Properties;
 4 
 5 /**
 6  * Created by sherry on 000024/6/24 23:08.
 7  */
 8 public class TestSystemProperty {
 9     public static void main(String[] args) {
10         //showSystemProperties();
11         /*获取某个系统属性*/
12         System.out.println(System.getProperty("java.version"));
13     }
14 
15     /**
16      * 遍历系统所有属性
17      */
18     private static void showSystemProperties() {
19         Properties properties = System.getProperties();
20         properties.list(System.out);
21     }
22 }
D:\GitHub\tools\JavaEEDevelop\Lesson1_JavaSe_Demo1\src\org\zln\usefulclass\system\TestSystemProperty.java

 

  遍历环境变量

 1     /**
 2      * 遍历环境变量
 3      */
 4     public static void showEnvProperties(){
 5         Map<String,String> map = System.getenv();
 6         Iterator<String> iterator = map.keySet().iterator();
 7         while (iterator.hasNext()){
 8             String k = iterator.next();
 9             String v = map.get(k);
10             System.out.println(k+":"+v);
11         }
12     }
遍历环境变量

 

posted @ 2015-06-24 23:40  csnmd  阅读(455)  评论(0编辑  收藏  举报