![在这里插入图片描述](https://img-blog.csdnimg.cn/20201224214430833.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzIxMzgzNDM1,size_16,color_FFFFFF,t_70)
1.概述
scala读取java项目下Src目录下的properties文件
![这里写图片描述](https://img-blog.csdnimg.cn/img_convert/58cc366f5e8758a59a8582ae19be50fe.png)
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的数据的值
}
}