object ConfigurationUtil {
def main(args: Array[String]): Unit = {
println(getValueFromConfig("config", "hive.database"))
}
def getValueFromConfig(path:String, key : String="config"): String = {
/*
Java中最基本的读取配置文件方式
val stream: InputStream = Thread.currentThread().getContextClassLoader.getResourceAsStream(path)
val properties = new Properties()
properties.load(stream)
properties.getProperty(key)
*/
// 读取配置文件:国际化(i18n)
val bundle: ResourceBundle = ResourceBundle.getBundle(path)
bundle.getString(key)
}
}