Skip to content

Instantly share code, notes, and snippets.

@kittinunf
Last active August 9, 2016 10:45
Show Gist options
  • Save kittinunf/8a23083b9e996d144f4de787f23f02ab to your computer and use it in GitHub Desktop.
Save kittinunf/8a23083b9e996d144f4de787f23f02ab to your computer and use it in GitHub Desktop.
fun doSomething(path: String) {
val content: String //instead of declare as `var content: String? = null`
val br = BufferedReader(FileReader(path))
var currentLine = br.readLine()
content = buildString {
while (currentLine != null) {
appendln(currentLine)
currentLine = br.readLine()
}
}
println(content) //print all content
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment