How to call String.getBytes()?


#1

I want to call String.getBytes(), but the editor says the method is unknown & the compiler gives me an unresolved reference.

This seems like a bug.

KT-7995 may be related, but getBytes() itself isn’t deprecated (although one of its overloads is deprecated).

Is there a workaround?

Thanks,
Neil


#2

Use String.toByteArray() extension: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/to-byte-array.html


#3

Thanks Ilya.

Was this method purposefully hidden?