Reputation: 1
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.
Upvotes: 0
Views: 771
Reputation: 6999
You can use anonymous object to get its class and then the class loader:
object {}.javaClass.classLoader.getResource("firebase.json")
Upvotes: 3