java獲取系統屬性

 System.getenv();//獲取系統所有的環境變量;
 System.getenv(String name);//獲取指定名稱的環境變量值;
 System.getProperties();//獲取所有系統屬性
 System.getProperty(String name);//獲取指定的系統屬性
 System.getProperty(String name,String def);//獲取指定的系統屬性,若系統不存在指定的屬性,則以默認值(def)返回
 Properties p=System.getProperties();//把系統屬性寫入到文本中
 p.store(new FileOutputStream("e:\\properties.txt"),"System properties");

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章