All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.xiaoyuge5201.prop.PropertyUtil Maven / Gradle / Ivy

There is a newer version: 1.3.5
Show newest version
package com.github.xiaoyuge5201.prop;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

/**
 * @author xiaoyuge
 */
public class PropertyUtil {

    private static Logger log = LoggerFactory.getLogger(PropertyUtil.class);

    private static Properties prop = new Properties();

	/**
	 * 获取文件的值
	 * @param fileName 文件名称
	 * @param key key
	 * @return 返回
	 */
    public static String getPropertyValue(String fileName, String key) {
        InputStream in = PropertyUtil.class.getResourceAsStream(fileName);
        String rtnValue = null;
        try {
            prop.load(in);
            rtnValue = prop.getProperty(key).trim();
        } catch (IOException e) {
            log.error("信息:" + e.toString(), e);
        }
        return rtnValue;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy