欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

读 properties  

程序员文章站 2022-07-13 21:34:09
...
public class PropUtil {

    private static String getKey(String key){
        Properties properties = new Properties();
        InputStream inputStream = PropUtil.class.getClassLoader().getResourceAsStream("system.properties");
        System.out.println(inputStream);
        try {
            properties.load(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
        String value  = properties.getProperty(key);
        return value;
    }

    public static void main(String[] args) {
//        System.out.println(getKey("appServerIp"));

        ResourceBundle resource = ResourceBundle.getBundle("system");
        System.out.println(resource.getString("appServerIp"));
    }
}

 

 https://blog.csdn.net/mhmyqn/article/details/7683909