0

I have a function that needs to load a json file, on the local server I can load using an absolute path, my question is how to program this path to work with me packaging the JAR file.

val serviceAccount = FileInputStream("C:/Users/Alan/Desktop/template-fullstack-ktor/src/backendMain/resources/firebase.json")

I believe that I need to create a dynamic path to the resource folder. But I'm a beginner and I don't know how to do that.

1 Answers1

2

You can use anonymous object to get its class and then the class loader:

object {}.javaClass.classLoader.getResource("firebase.json")
Aleksei Tirman
  • 4,658
  • 1
  • 5
  • 24