shamanthOriginal post
Rank 1: Thread
My function structure looks like this:
kotlin
- src
- Main.kt
- static
- index.html
Entry point for the function is src/Main.kt
I'm getting java.lang.reflect.InvocationTargetException and Caused by: java.io.FileNotFoundException: ../static/index.html (No such file or directory) errors.
The code I'm using to read files is:
Plain text
val text = File("../static/index.html").readText()I've also tried
Plain text
val fileName = Paths.get("..", "static", "index.html")val fileString = Files.readString(fileName)and many others without any luck.
Summary
The issue is that static files are not found in Kotlin functions because they are not bundled into the jar file when the Kotlin code is compiled. A potential solution is to update open runtimes to support static files. The provided code snippets to read the file have not worked so far.