如何读取一个BufferedReader
行的所有并存储到一个字符串中?
val br = new BufferedReader(...)
val str: String = getAllLines(br) // getAllLines() -- is where I need help
类似于此question。
发布于 2013-09-21 03:50:28
这是我在Scala中处理BufferedReader
的方式:
val br:BufferedReader = ???
val strs = Stream.continually(br.readLine()).takeWhile(_ != null)
读取器中的每一行都有一个字符串。如果你想把它放在一个单独的字符串中:
val str = Stream.continually(br.readLine()).takeWhile(_ != null).mkString("\n")
https://stackoverflow.com/questions/18923864
复制相似问题