How to invoke external command from within Kotlin code?

后端 未结 7 1420
花落未央
花落未央 2020-11-29 22:08

I want to invoke an external command from Kotlin code. In C/Perl, I would use system() function. In Python, I would use the subprocess module. In Go, I would us

7条回答
  •  無奈伤痛
    2020-11-29 22:33

    For Kotlin Native:

    platform.posix.system("git status")
    

    For JVM

    Runtime.getRuntime().exec("git status")
    

提交回复
热议问题