【发布时间】:2021-11-22 05:40:45
【问题描述】:
下面是我的项目结构。我试图在下面的程序中读取我的属性文件pgmproperties.properties,但收到错误File Not found。请告诉我我应该把我的文件放在哪里。我正在使用 SBT 构建工具。
我的代码
def main(args: Array[String]) {
// This is used to read Properties files and get the values
val is: InputStream = ClassLoader.getSystemResourceAsStream("pgmproperties.properties")
val prop: Properties = new Properties()
if (is != null) {
prop.load(is)
}
else {
throw new FileNotFoundException("Properties file cannot be loaded")
}
val sndrmailid = prop.getProperty("SndrMailId") //Sender Mail id
val psswd = prop.getProperty("SndrMailPsswd") //Sender gmail Mailbox id password
val tomailid = prop.getProperty("RcvrMailId") // Receiver email id.
println( sndrmailid )
}
【问题讨论】:
标签: scala apache-spark intellij-idea