1.原来读取文件的方式
def getProperties(path : String) : Properties = {
val p = Thread.currentThread().getContextClassLoader.getResource(path).getPath
val prop = new Properties()
prop.load(new FileInputStream(p))
return prop
}
2.修改读取文件的方式为
def getProperties(path : String) : Properties = {
val p = PropertiesUtils.getClass.getClassLoader.getResourceAsStream(path)
val prop = new Properties()
prop.load(p)
return prop
}
3.使用这种方式就能够读取jar包中的文件了,因为jar包文件读取和我们平时的文件系统java类似