public final class Environment extends Object
Modifier and Type | Method and Description |
---|---|
void |
appendPath(String name,
String value)
Appends a path to a path-like variable.
|
String |
getVariable(String name)
Returns the value of the variable or
null . |
void |
prependPath(String name,
String value)
Prepends a path to a path-like variable.
|
void |
removeVariable(String name)
Removes a variable with the given name.
|
void |
setVariable(String name,
String value)
Sets a value for a variable with the given name.
|
Map<String,String> |
values()
Returns all variable names and associated values as a
Map . |
@CheckForNull public String getVariable(@NonNull String name)
null
.name
- the name of the variablenull
public void appendPath(@NonNull String name, @NonNull String value)
name
- the name of the variable such as for example
PATH
or LD_LIBRARY_PATH
value
- the value (path to append)public void prependPath(@NonNull String name, @NonNull String value)
name
- the name of the variable such as for example
PATH
or LD_LIBRARY_PATH
value
- the value (path to prepend)public void setVariable(@NonNull String name, @NonNull String value)
name
- the name of the variablevalue
- the valuepublic void removeVariable(@NonNull String name)
Environment.getVariable(java.lang.String)
with the same argument will return
null
.name
- the name of the variable