Skip to main content
Version: 1.0.18

How to Access System Information?

Sometimes, environment variables are relevant information to an application. ZIO provides a system package to interface with this functionality.

import zio.system

Environment Variables

With the env method, you can safely read an environment variable:

// Read an environment variable
// res0: zio.ZIO[system.package.System, SecurityException, Option[String]] = zio.ZIO$Read@2111d7b9


With the property method, you can safely access Java properties:

// Read a system property"java.version")
// res1: zio.ZIO[system.package.System, Throwable, Option[String]] = zio.ZIO$Read@7a023e34


With the lineSeparator method, you can determine the line separator for the underlying platform:

// res2: zio.package.URIO[system.package.System, String] = zio.ZIO$Read@260f05ee