集合
集合文档: https://docs.scala-lang.org/zh-cn/overviews/collections/introduction.html
- JAVA和SCALA容器的转换:https://docs.scala-lang.org/zh-cn/overviews/collections/conversions-between-java-and-scala-collections.html
seq文档:https://www.scala-lang.org/api/current/scala/collection/Seq.html
模式匹配
优雅文件读取
import scala.io.Source
import scala.util.{Try,Success,Failure}
object Test extends App {
def readTextFile(filename: String): Try[List[String]] = {
Try(Source.fromFile(filename).getLines.toList)
}
val filename = "/etc/passwd"
readTextFile(filename) match {
case Success(lines) => lines.foreach(println)
case Failure(f) => println(f)
}
}
线程池
使用java并发包中的线程池工具 https://blog.csdn.net/liam08/article/details/101647064