I created a file with single line:
➜ ~ vi some_random_file_mkstring
➜ ~ wc -l < some_random_file_mkstring
1
When I read the file using Source.fromFile
and create a string using mkString
it appends a newLine but if I do .getLines().mkString
it doesn't append a newLine character.
scala> io.Source.fromFile("some_random_file_mkstring").mkString
res0: String =
"somerandomstring
"
scala> io.Source.fromFile("some_random_file_mkstring").mkString.contains("\n")
res1: Boolean = true
scala> io.Source.fromFile("some_random_file_mkstring").getLines().mkString.contains("\n")
res2: Boolean = false
Is this desired behavior? I am using scala 2.12.4