Simplify some LyricUtil methods with Kotlin
This commit is contained in:
parent
e31898a8ec
commit
c264c28840
1 changed files with 3 additions and 16 deletions
|
@ -132,27 +132,14 @@ object LyricUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
private fun convertStreamToString(`is`: InputStream): String {
|
private fun convertStreamToString(inputStream: InputStream): String {
|
||||||
val reader = BufferedReader(InputStreamReader(`is`))
|
return inputStream.bufferedReader().readLines().joinToString(separator = "\n")
|
||||||
val sb = StringBuilder()
|
|
||||||
var line: String?
|
|
||||||
while (reader.readLine().also { line = it } != null) {
|
|
||||||
sb.append(line).append("\n")
|
|
||||||
}
|
|
||||||
reader.close()
|
|
||||||
return sb.toString()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getStringFromLrc(file: File?): String {
|
fun getStringFromLrc(file: File?): String {
|
||||||
try {
|
try {
|
||||||
val reader = BufferedReader(FileReader(file))
|
val reader = BufferedReader(FileReader(file))
|
||||||
val sb = StringBuilder()
|
return reader.readLines().joinToString(separator = "\n")
|
||||||
var line: String?
|
|
||||||
while (reader.readLine().also { line = it } != null) {
|
|
||||||
sb.append(line).append("\n")
|
|
||||||
}
|
|
||||||
reader.close()
|
|
||||||
return sb.toString()
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.i("Error", "Error Occurred")
|
Log.i("Error", "Error Occurred")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue