qileilove

          blog已經轉移至github,大家請訪問 http://qaseven.github.io/

          如何使用Java讀寫系統屬性?

           如何使用Java讀寫系統屬性?
            讀:
          Properties props = System.getProperties();
          Enumeration prop_names = props.propertyNames();
          while (prop_names.hasMoreElements()) {
          String prop_name = (String) prop_names.nextElement();
          String property = props.getProperty(prop_name);
          System.out.println(“Property ‘” + prop_name + “‘ is ‘”+ property + “‘”);
          }
            寫:
            System.setProperties(props);
            簡述properties文件的結構和基本用法
            結構:擴展名為properties的文件,內容為key、value的映射,例如”a=2″
            用法:
          public class Test {
          public static void main(String args[]) {
          try {
          String name = “test.properties”;
          InputStream in = new BufferedInputStream(new FileInputStream(name));
          Properties p = new Properties();
          p.load(in);
          System.out.println(“a的值==” + p.getProperty(“a”));
          } catch (Exception err) {
          err.printStackTrace();
          }
          }
          }

          posted on 2014-11-26 14:55 順其自然EVO 閱讀(214) 評論(0)  編輯  收藏 所屬分類: 測試學習專欄

          <2014年11月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          30123456

          導航

          統計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 长武县| 聊城市| 信宜市| 浮山县| 耿马| 洛宁县| 德昌县| 卓尼县| 南开区| 江孜县| 姚安县| 武威市| 岳普湖县| 鲁山县| 河南省| 田东县| 江北区| 六安市| 营口市| 交城县| 乌鲁木齐市| 客服| 黄龙县| 焦作市| 当涂县| 呼图壁县| 醴陵市| 青州市| 历史| 靖安县| 崇信县| 仙居县| 上林县| 彩票| 海安县| 赣州市| 湘乡市| 德州市| 贵德县| 鄂温| 防城港市|