我是Scala编程的新手,我想在Scala中读取属性文件.
我找不到任何API来读取Scala中的属性文件.
如果有任何API用于读取Scala中的属性文件,请告知我们.
Jat*_*tin 17
你将不得不使用Scala做它用类似的方式将Map
到java.util.Map
.java.util.Properties
延伸到java.util.HashTable
哪个延伸java.util.Dictionary
.
scala.collection.JavaConverters
具有转换Dictionary
为Scala的功能mutable.Map
:
val x = new Properties
//load from .properties file here.
import scala.collection.JavaConverters._
scala> x.asScala
res4: scala.collection.mutable.Map[String,String] = Map()
Run Code Online (Sandbox Code Playgroud)
然后你可以使用Map
上面的.获取和检索.但是如果你想将它转换回Properties
类型(存储回来等),你可能必须手动输入它.