import java.io.InputStreamReader
import java.util.Properties
object PropertiesUtil {
/**
* 读取配置文件返回配置对象
* @param propertieName config.properties 配置文件名
* @return properties: Properties对象
*/
def load(propertieName:String): Properties ={
val prop = new Properties()
// todo 读取配置文件
prop.load(new InputStreamReader(Thread.currentThread().getContextClassLoader.getResourceAsStream(propertieName),"UTF-8"))
prop
}
// 测试
def main(args: Array[String]): Unit = {
val properties: Properties = load("config.properties")
val str: String = properties.getProperty("redis.host")
println(str)
}
}