In Kotlin/Native with Gradle, is there a way to re...
# kotlin-native
t
In Kotlin/Native with Gradle, is there a way to read a resource file from native code similar to how it's done in JVM? I need a Kotlin/Native equivalent for the following JVM code:
Copy code
val inputStream = object {}.javaClass.getResourceAsStream("/sample.txt")
    val content = inputStream.bufferedReader().use(BufferedReader::readText)
l
I had exactly the same need, and I was told there is no such way. That said, you could always embed the data in an elf file, link it to an
.so
and then use cinterop to include it.
k
Nope. I was met maybe not similar but close enough issues with resources so I've created few utilities by using the POSIX interop on linux/mac
For a new small binary files , i convert it into base64 text and store it as raw string in kotlin source…it’s really painful to deal with embedded resources (which works on all native platforms) today.