Check if a user is root in a java application

前端 未结 7 703
日久生厌
日久生厌 2021-02-08 09:25

How can i verify if a user is root in a java application?

Thanks

7条回答
  •  囚心锁ツ
    2021-02-08 10:10

    You can call

      Process p = Runtime.getRuntime.exec("whoami")
    

    method. Then you can process p's stdout to read output of command.

提交回复
热议问题