Hi all, I am porting some Kotlin/JVM code to Kotlin/Native - original logic relied heavily on ByteBuffer, which was used for parsing Float / Double / Long etc.. values out of one long ByteArray. In Kotlin Native ByteBuffer is not available, is there some easy way to parse ByteArray contents? I am using Kotlin 1.3.71
z
Zach Klippenstein (he/him) [MOD]
04/27/2020, 1:42 PM
You could use okio, it has a really nice API for that kind of thing and supports both jvm and native: https://github.com/square/okio
Wow nice hint, thank you. I have tried to implement it using OKIO and it works well. Is okio multiplatform used somewhere in production on iOS somewhere? I need this info for feasibility study.
z
Zach Klippenstein (he/him) [MOD]
04/28/2020, 5:57 PM
I’m not aware of anyone using Okio in production on iOS, but if you look at the code I linked it’s almost entirely just delegating back to the common implementation, which is the same code used by the JVM targets. And the JVM okio library is used extensively by tons of android apps, and even in the Android framework itself.