Skip to main content
Version: ZIO 1.x

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@3e9bcc09


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@50ae9d8f


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@1cde9048