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(); } } }
如有疑问,欢迎留言讨论。
原文地址:https://www.cnblogs.com/zhhy/p/9800224.html