標籤:
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 }遍曆環境變數
Java常用實體類