Package org.apache.commons.exec.environment

# Class EnvironmentUtils

java.lang.Object
org.apache.commons.exec.environment.EnvironmentUtils

public class EnvironmentUtils extends Object
Wraps environment variables.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `addVariableToEnvironment(Map<String,String> environment, String keyAndValue)`
  Adds a key/value pair to the given environment.
  `static Map<String,String>`
  `getProcEnvironment()`
  Gets the list of environment variables for this process.
  `static String[]`
  `toStrings(Map<String,String> environment)`
  Converts a variable map as an array.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### addVariableToEnvironment

    public static void addVariableToEnvironment(Map<String,String> environment, String keyAndValue)
    Adds a key/value pair to the given environment. If the key matches an existing key, the previous setting is replaced.
    Parameters:
      `environment` - the current environment.
      `keyAndValue` - the key/value pair.

  - ### getProcEnvironment

    public static Map<String,String> getProcEnvironment() throws IOException
    Gets the list of environment variables for this process. The returned map preserves the casing of a variable's name on all platforms but obeys the casing rules of the current platform during lookup, e.g. key names will be case-insensitive on Windows platforms.
    Returns:
      a map containing the environment variables, may be empty but never `null`.
    Throws:
      `IOException` - the operation failed.

  - ### toStrings

    public static String[] toStrings(Map<String,String> environment)
    Converts a variable map as an array.
    Parameters:
      `environment` - the environment to use, may be `null`.
    Returns:
      array of key=value assignment strings or `null` if and only if the input map was `null`.