How to get absolute path of my project or current working directory in Kotlin
Super simple trick to get the path of of your project folder in kotlin. You can also use this example snippet for your java or spring project as well.
Example location of your main file
/Users/my-user/code/my-project/src/main/kotlin/com.myproject/Main.kt
Getting project root directory
It doesn't matter where you define you define this function or from where you call, it will always will return you the absolute path of your project.
/Users/my-user/code/my-project/
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login.