user
11/07/2017, 6:56 PMhttps://kotlinlang.slack.com/files/U7VTJDE4R/F7WDEPK1Q/screen_shot_2017-11-07_at_1.40.08_pm.png▾
fun readFromFile(path: String, newLine: Boolean): String {
val text = StringBuilder()
val separator = System.getProperty("line.separator")
return FileReader(path).use { fileReader ->
BufferedReader(fileReader).forEachLine {
text.append(it)
if (newLine) text.append(separator)
}
text.toString()
}
}