How can I use a Java String method (split) directly from Kotlin source?

Viewed 1468

Doing some profiling, it seems my bottleneck is the Kotlin kotlin.CharSequence.split() extension function.

My code just does something like this:

val delimiter = '\t'
val line = "example\tline"
val parts = line.split(delimiter)

As you might notice, parts is a List<String>.

I wanted to benchmark using Java's split directly, which returns a String[] and might be more efficient.

How can I call Java's String::split(String) directly from Kotlin source?

2 Answers
Related