ヘッダーとフッターの文字列を含む文字列のリストを作成しようとしています。主な内容はローカルで読み取られるファイルです。以下のテキスト ファイル「textFile」には、文字列のリストが含まれています。
これが私が試していることです:
var fileList = List[String]()
val bigFile = io.Source.fromFile("d:\\textFile.txt")
val groupedLines = bigFile.getLines.grouped(20000).zipWithIndex
groupedLines.foreach(group => {
val (lines, index) = group
fileList.addString(new StringBuilder("begin"))
//How can I add the contents of the file here to the val fileList ???
fileList.add(lines.)
fileList.addString(new StringBuilder("end"))
}