import scala.io.Source
object wordcount1 {
def main(args: Array[String]): Unit = {
Source.fromFile("D:\\Big_Data\\myscala\\data\\words.txt").getLines().flatMap(_.split(",")).map((_, 1)).toList.groupBy(_._1).map(x => (x._1, x._2.map(_._2).sum)).foreach(println)
}
}
Shock! Scala one line of code to achieve wordcount! ! !
Guess you like
Origin blog.csdn.net/qq_45750230/article/details/107855742
Recommended
Ranking