How to read resources using kotlin
已回答
I'm new to kotlin, creating plugin using Kotlin.
I have properties file added to resources folder, want to read proprerties file using kotlin
Project:
I tried the same using java, i was able to achieve from the below code
JAVA:
this.getClass().getClassLoader().getResource("app.properties").getPath();
I just need the similar code for the above, i tried below but im getting below location where its searching for properties. But properties file is not the location where its searching for
file: /Users/smadhavan/IdeaProjects/MyPlugin/build/idea-sandbox/plugins/kotlin/lib/kotlin-1.0-SNAPSHOT.jar!/app.properties
KOTLIN:
this.javaClass.classLoader.getResource("app.properties").path
Thanks
请先登录再写评论。
Have you checked com.intellij.util.ResourceUtil class?
I tried ResourceUtil class, but still its searching file folder from below location
/Users/smadhavan/IdeaProjects/MyPlugin/build/idea-sandbox/plugins/kotlin/lib/kotlin-1.0-SNAPSHOT.jar!/
I also manually mentioned the resources folder as "Resource root" on right-clicking on the folder but still no luck
Thanks Chrisly, for the reply
Found solution for the above issue. Below code works