首页 > 其他 > 详细

Properyies文件的读取

时间:2018-01-02 22:12:29      阅读:325      评论:0      收藏:0      [点我收藏+]

当我们使用Properyies存储数据的时候是以键值对形式的,可以存储到Map数据中,我们就可以用前面的key值来获取后面的value

public Map<String,String> getProperyies(){
        Properties properties = new Properties();
        Map<String, String> stringStringHashMap = new HashMap<>();
        InputStream resourceAsStream = getClass().getResourceAsStream("type.peoperyies");
        try {
            properties.load(resourceAsStream);
            Enumeration<?> enumeration = properties.propertyNames();
            while(enumeration.hasMoreElements()){
                String o = (String) enumeration.nextElement();
                String property = properties.getProperty(o);
                stringStringHashMap.put(o,property);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
          return stringStringHashMap;
    }

这就是Properyies文件的读取!小伙伴赶快试一试吧!

Properyies文件的读取

原文:https://www.cnblogs.com/cainiaodongdong/p/8179043.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!