配置文件读取名值对

    Properties props = test.readProperties(filepath);//此对象方法返回加载好的Properties

    
    Enumeration enA = props.propertyNames();
    while (enA.hasMoreElements()) {
     String Akey = (String) enA.nextElement();
     String Property = props.getProperty(Akey);
     System.out.println(Akey+" ---- " + Property);
    }

 

    Enumeration en = props.elements();//这个方法取到的是值,没有名
    while (en.hasMoreElements()) {
     String tmpKey = (String) en.nextElement();

     String tmpvalue = (String) props.getProperty(tmpKey);//以值为名,取值,若不存在这个值的名,取出来肯定是null
   %>
   key : <%=tmpKey%>
   value: <%=tmpvalue%><br>
   <%
    }

posted on 2014-08-18 10:59  山冈龙  阅读(112)  评论(0编辑  收藏  举报

导航