获取属性文件的值

public class Configuration {

    private static int pageSize;

    static {
        Properties prop = new Properties(); 
        InputStream inputStream=Object.class.getResourceAsStream("/default.properties");
        try {
            prop.load(inputStream);
            pageSize=Integer.valueOf(prop.getProperty("pageSize"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public static int getPageSize() {
        return pageSize;
    }

}

 

posted @ 2016-07-29 10:51  HappyCowboy  阅读(178)  评论(0)    收藏  举报