2b3e9fa689
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@153 a672b425-5310-4d7a-af5c-997e18724b81
28 lines
648 B
Kotlin
28 lines
648 B
Kotlin
/*
|
|
* Copyright (c) 2018. Bevilacqua Joey
|
|
*/
|
|
package ch.usi.inf.atelier.group1.util.extensions
|
|
|
|
import ch.usi.inf.atelier.group1.util.Log
|
|
import java.io.BufferedReader
|
|
import java.io.File
|
|
import java.io.FileReader
|
|
import java.io.IOException
|
|
|
|
fun File.getContent(): String {
|
|
val content = StringBuilder()
|
|
try {
|
|
val reader = BufferedReader(FileReader(this))
|
|
var line: String? = ""
|
|
|
|
while (line != null) {
|
|
content.append(line)
|
|
.append('\n')
|
|
line = reader.readLine()
|
|
}
|
|
} catch (e: IOException) {
|
|
Log.e(exception = e)
|
|
}
|
|
|
|
return content.toString()
|
|
} |