java读取配置文件写法

来源:互联网 发布:排名软件 编辑:程序博客网 时间:2024/05/08 17:20
package com.lile.util;

import java.io.InputStream;
import java.util.Properties;

public class PropertiesUtil {
    
    public static String getValue(String key){
        
        Properties properties = new Properties();
        InputStream is = new PropertiesUtil().getClass().getResourceAsStream("/diary.properties");
        
        try{
            properties.load(is);
        }catch(Exception e){
            
        }
        return (String)properties.get(key);
    }
}
0 0
原创粉丝点击