For example, Groovy allows to get text of a file represented by java.nio.file.Path as follows:
// Groovy code
import java.nio.file.Path
import java.nio.file.Paths
Path p = Paths.get("data.txt")
String text = p.text
I would like to be able to reuse Groovy's text extension method in Kotlin.
Please note: I know Kotlin has a related method for this particular case. Still, there might be Groovy methods which are useful for Kotlin users.
One way is to write a simple wrapper extension function in Kotlin:
Which then can be used like:
If using Gradle to build the project, this means Groovy has to be added to dependencies: