java文件读取

来源:互联网 发布:触摸交互式软件 编辑:程序博客网 时间:2024/06/08 17:18
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;


import org.apache.log4j.Logger;

public class MgjrProperties {

private static Properties properties = null;

private static Logger logger = Logger.getLogger(MgjrProperties.class);

protected static synchronized Properties getProperties() {
        if (properties == null) {
            properties = new Properties();
            try {
            ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
                properties.load(new InputStreamReader(classLoader.getResourceAsStream("mgjr_param.properties"),"UTF-8"));
            } catch (IOException e) {
            logger.error("读取mgjr_param.properties失败!", e);
            }
        }
        return properties;

    }

原创粉丝点击