package com.nuvole.util;
|
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.core.io.DefaultResourceLoader;
|
import org.springframework.core.io.ResourceLoader;
|
|
import java.io.IOException;
|
import java.io.InputStream;
|
import java.util.Properties;
|
|
/**
|
* 读取配置文件
|
*
|
* @Author: lc
|
* @Date: 2019/6/13 15:31
|
*/
|
@Slf4j
|
public class PropertyUtil {
|
|
public static String getProp(String fileName, String k) {
|
Properties props = new Properties();
|
InputStream in = null;
|
try {
|
ResourceLoader resourceLoader = new DefaultResourceLoader();
|
in = resourceLoader.getResource(fileName).getInputStream();
|
props.load(in);
|
return props.getProperty(k);
|
} catch (IOException e) {
|
e.printStackTrace();
|
return "";
|
} finally {
|
ResourceUtil.safeClose(in);
|
}
|
}
|
}
|