首页 > 编程语言 > 详细

java-读取属性文件

时间:2016-10-18 20:24:35      阅读:158      评论:0      收藏:0      [点我收藏+]

Property类:

public static Properties loadLocalProperties(String fileName) {
        Properties property = new Properties();

        try {
            String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();
            InputStream in = new BufferedInputStream(new FileInputStream(path + "/" + fileName));
            property.load(in);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return property;
    }

 

ResourceBundle类:

public static ResourceBundle loadLocalProperties2(String fileName) {
        return ResourceBundle.getBundle(fileName, Locale.getDefault());
    }

 

java-读取属性文件

原文:http://www.cnblogs.com/DengGao/p/5974750.html

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