Simplify some LyricUtil methods with Kotlin

This commit is contained in:
TacoTheDank 2022-04-07 17:36:24 -04:00
parent e31898a8ec
commit c264c28840

View file

@ -132,27 +132,14 @@ object LyricUtil {
}
@Throws(Exception::class)
private fun convertStreamToString(`is`: InputStream): String {
val reader = BufferedReader(InputStreamReader(`is`))
val sb = StringBuilder()
var line: String?
while (reader.readLine().also { line = it } != null) {
sb.append(line).append("\n")
}
reader.close()
return sb.toString()
private fun convertStreamToString(inputStream: InputStream): String {
return inputStream.bufferedReader().readLines().joinToString(separator = "\n")
}
fun getStringFromLrc(file: File?): String {
try {
val reader = BufferedReader(FileReader(file))
val sb = StringBuilder()
var line: String?
while (reader.readLine().also { line = it } != null) {
sb.append(line).append("\n")
}
reader.close()
return sb.toString()
return reader.readLines().joinToString(separator = "\n")
} catch (e: Exception) {
Log.i("Error", "Error Occurred")
}