首页 > 编程语言 > 详细

java读取properties文件工具

时间:2016-10-20 21:12:30      阅读:201      评论:0      收藏:0      [点我收藏+]
public class PropertiesUtil {

    public static String get(String filePath, String key) {
        String val = null;
        Properties prop = new Properties();
        InputStream in = null;
        in = PropertiesUtil.class.getClassLoader().getResourceAsStream(filePath);
        try {
            prop.load(in);
            val = (String) prop.get(key);
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return val;
    }
}

 

java读取properties文件工具

原文:http://www.cnblogs.com/windyWu/p/5982173.html

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