我如何阅读 全部 的 BufferedReader
的行并存储到字符串中?
val br = new BufferedReader(...)
val str: String = getAllLines(br) // getAllLines() -- is where I need help
与此类似 question .
最佳答案
这就是我处理 BufferedReader
的方式在斯卡拉:
val br:BufferedReader = ???
val strs = Stream.continually(br.readLine()).takeWhile(_ != null)
阅读器的每一行都会有一个字符串。如果你想在一个字符串中使用它:
val str = Stream.continually(br.readLine()).takeWhile(_ != null).mkString("\n")
关于scala - 将Scala中BufferedReader的所有行读入一个字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18923864/