案例
import scala.io.Source
object FileSyllabus {
def main(args: Array[String]): Unit = {
val buffered_Source1 = Source.fromFile("E:\\ scala_project\\2019.log", "UTF-8")
val lines = buffered_Source1.getLines()
for (line <- lines){
println(line)
}
buffered_Source1.close
}
}
文件内容转数组
val array= buffered_Source1.getLines.toArray
文件内容转字符串
val iterator = buffered_Source1.mkString