Scala WordCount
def wordCount(){ //scala worldcountS
val map = scala.collection.mutable.Map[String,Int]()
val in = Source.fromFile("/home/yc/Desktop/1").getLines()
for(i<-in) map(i) = map.getOrElse(i, 0)+1
println(map.mkString("\n"))
}
Scala 文本倒序输出
def test2{ //倒序输出文本
val in = Source.fromFile("/home/yc/Desktop/1").getLines()
val result = in.toArray.reverse
val out = new PrintWriter("/home/yc/Desktop/2")
result.foreach { p => out.println(p) }
out.close()
}