zoukankan      html  css  js  c++  java
  • java读取自定义配置文件并引用

    首先在resources目录创建自定义的配置文件

     配置文件的格式:

     写工具类,得到配置参数

    import java.io.IOException;
    import java.io.InputStream;
    import java.util.Properties;
    
    public class MyConfig {
        public static Properties myProp = new Properties();
        public static InputStream myResource = MyConfig.class.getResourceAsStream("/myConfig.properties");
        static {
            try {
                myProp.load(myResource);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        public String getMyConf(String props) {
            return myProp.getProperty(props);
        }
        
        public static void main(String[] args) {
            final MyConfig myConfig = new MyConfig();
            System.out.println(myConfig.getMyConf("master_ip"));
        }
    }
  • 相关阅读:
    PHP入门
    requests中text,content,json之间的区别
    有关pip报错的问题

    pycharm操作
    python selenium 相关操作
    python tkinter菜单
    初识Go
    Python _easygui详细版
    easygui _1
  • 原文地址:https://www.cnblogs.com/yoyowin/p/13171654.html
Copyright © 2011-2022 走看看