自己编写读取配置文件的信息的方法

版权声明:A_芦瑞华_i_DO.欢迎转载 https://blog.csdn.net/weixin_43067223/article/details/84982605

在这里插入图片描述结果:
在这里插入图片描述

代码:

public static void main(String[] args) {
    //自己编写的读取配置文件的方法
    InputStream inputStream = FtpConfig.class.getResourceAsStream("/ftp.properties");
    Properties properties =new Properties();//Map接口的实现类
    try {
        properties.load(inputStream);
        //System.out.println(properties.get("mybatis.typeAliasesPackage")+"............");
        Set<Object> objects = properties.keySet();//返回map的所有key
        //objects.iterator(); 遍历map至少要知道2种方法
        for (Object object : objects) {
            System.out.println("key:"+object+",value:"+properties.get(object));
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

猜你喜欢

转载自blog.csdn.net/weixin_43067223/article/details/84982605