1.概述
scala读取java项目下Src目录下的properties文件
package scala
import java.util.Properties
import java.io.FileInputStream
import scala.tools.scalap.Main
object PropertiesScalaUtils {
def loadProperties(key:String):Unit = {
val properties = new Properties()
val in = PropertiesScalaUtils.getClass.getClassLoader.getResourceAsStream("config_scala.properties")
//val path = Thread.currentThread().getContextClassLoader.getResource("config_scala.properties").getPath //文件要放到resource文件夹下
properties.load(in);
println(properties.getProperty(key))//读取键为ddd的数据的值
}
}