splitLongs: Handle NumberFormatException

This commit is contained in:
Alinson S. Xavier 2022-09-08 20:43:14 -05:00
parent 11f726064a
commit 961fb7618f
No known key found for this signature in database
GPG Key ID: 0DA8E4B9E1109DCA

View File

@ -25,6 +25,12 @@ class StringUtils {
fun joinLongs(values: LongArray): String = values.joinToString(separator = ",")
fun splitLongs(str: String): LongArray = str.split(",").map { it.toLong() }.toLongArray()
fun splitLongs(str: String): LongArray {
return try {
str.split(",").map { it.toLong() }.toLongArray()
} catch (e: NumberFormatException) {
LongArray(0)
}
}
}
}