How to read environment variables in Scala

前端 未结 6 611
渐次进展
渐次进展 2020-12-12 13:23

In Java, reading environment variables is done with System.getenv().

Is there a way to do this in Scala?

6条回答
  •  攒了一身酷
    2020-12-12 14:18

    There is an object:

    scala.util.Properties
    

    this has a collection of methods that can be used to get environment info, including

    scala.util.Properties.envOrElse("HOME", "/myhome" )
    

提交回复
热议问题