java拾遗录(二)

属性文件的读取:

public class pro_Test {

    public static void main(String[] args) throws Exception {
        Properties p = new Properties();
        p.load(new FileInputStream(new File("enum.ini")));
        for(Enumeration<?> e = p.propertyNames(); e.hasMoreElements();){
            String name = (String)e.nextElement();
            String attribute = p.getProperty(name);
            
            System.out.println("key : value = "  + name + " : " + attribute);
            
        }
    }

}

属性文件中的内容:

web1 = 101
web2 = 202
web3 = 303

键值对用等号隔开

变量的作用域:

1.class A  有变量a  = 100; class B 继承于A并且也有变量a = 1 那么当产生B的实例并且调用B.a 时,a 的值将是1

 

 

posted @ 2013-05-25 21:40  拙急鸟  阅读(118)  评论(0编辑  收藏  举报