How does reading files with kotlin work? I want to...
# announcements
a
How does reading files with kotlin work? I want to read a json file and parse it, im on a javascript with gradle project
n
In JVM, this would be something like
File("f.json").readText()
. I never used Ktlin with JS, but would https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.files/-file-reader/read-as-text.html help?
a
I'm not sure how to use java.io in a js project, what do i have to include in my gradle file?
l
You cannot use java.io in Kotlin/JS. You need to use JS APIs instead, browser or nodejs APIs depending on what you target
a
Thanks! I ended up using the fs node module