码迷,mamicode.com
首页 > 编程语言 > 详细

java-读取属性文件

时间:2016-10-18 20:26:50      阅读:198      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!