博主头像
Cool

行动起来,活在当下

  • 累计撰写 263 篇文章
  • 累计创建 159 个标签
  • 累计收到 0 条评论

目录

默认分类

使用Properties对象读取properties文件

使用Properties对象读取properties文件

使用Properties对象读取properties文件

        //定位类的根目录
        ClassLoader classLoader= App.class.getClassLoader();
        InputStream ins = classLoader.getResourceAsStream("pro.properties");
        
        //1.1创建Properties对象
        Properties properties=new Properties();
        //1.2加载配置文件,转换为一个集合
        properties.load(ins);
        String name = properties.getProperty("name");

pro.properties 内容

name=admin

那年今日12 月 4 日

    评论区