java中读取配置文件

配置文件:system.properties

内容格式,比如:shiyishi=haode

java代码如下

import java.util.Properties;

public class SystemParameter {
    private static  Properties pro;
    public static String CHANGLIANGE;

    static{
        try {
            pro=new java.util.Properties();
            pro.load(new SystemParameter().getClass().getClassLoader().getResourceAsStream("system.properties"));
            
CHANGLIANGE = pro.getProperty("shiyishi"); } catch (Exception e) { e.printStackTrace(); } } }

 

posted @ 2018-10-16 19:47  小哥哥呀  阅读(213)  评论(0编辑  收藏  举报