Package org.springframework.util

# Class SystemPropertyUtils

java.lang.Object
org.springframework.util.SystemPropertyUtils

public abstract class SystemPropertyUtils extends Object
Helper class for resolving placeholders in texts. Usually applied to file paths.

A text may contain `${...}` placeholders, to be resolved as system properties: for example, `${user.dir}`. Default values can be supplied using the ":" separator between key and value.

Since:
  1.2.5
Author:
  Juergen Hoeller, Rob Harrop, Dave Syer
See Also:
  - `PLACEHOLDER_PREFIX`
  - `PLACEHOLDER_SUFFIX`
  - `System.getProperty(String)`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final Character`
`ESCAPE_CHARACTER`
Escape character for property placeholders: `'\'`.
`static final String`
`PLACEHOLDER_PREFIX`
Prefix for property placeholders: "${".
`static final String`
`PLACEHOLDER_SUFFIX`
Suffix for property placeholders: "}".
`static final String`
`VALUE_SEPARATOR`
Value separator for property placeholders: ":".

## Constructor Summary

Constructors
Constructor
Description
`SystemPropertyUtils()`

## Method Summary

Modifier and Type
Method
Description
`static String`
`resolvePlaceholders(String text)`
Resolve `${...}` placeholders in the given text, replacing them with corresponding system property values.
`static String`
`resolvePlaceholders(String text, boolean ignoreUnresolvablePlaceholders)`
Resolve `${...}` placeholders in the given text, replacing them with corresponding system property values.

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

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

## Field Details

### PLACEHOLDER_PREFIX

public static final String PLACEHOLDER_PREFIX
Prefix for property placeholders: "${".

See Also:
  - Constant Field Values

### PLACEHOLDER_SUFFIX

public static final String PLACEHOLDER_SUFFIX
Suffix for property placeholders: "}".

See Also:
  - Constant Field Values

### VALUE_SEPARATOR

public static final String VALUE_SEPARATOR
Value separator for property placeholders: ":".

See Also:
  - Constant Field Values

### ESCAPE_CHARACTER

public static final Character ESCAPE_CHARACTER
Escape character for property placeholders: `'\'`.

Since:
  6.2

## Constructor Details

### SystemPropertyUtils

public SystemPropertyUtils()

## Method Details

### resolvePlaceholders

public static String resolvePlaceholders(String text)
Resolve `${...}` placeholders in the given text, replacing them with corresponding system property values.

Parameters:
  `text` - the String to resolve
Returns:
  the resolved String
Throws:
  `IllegalArgumentException` - if there is an unresolvable placeholder
See Also:
  - `PLACEHOLDER_PREFIX`
  - `PLACEHOLDER_SUFFIX`

### resolvePlaceholders

public static String resolvePlaceholders(String text, boolean ignoreUnresolvablePlaceholders)
Resolve `${...}` placeholders in the given text, replacing them with corresponding system property values. Unresolvable placeholders with no default value are ignored and passed through unchanged if the flag is set to `true`.

Parameters:
  `text` - the String to resolve
  `ignoreUnresolvablePlaceholders` - whether unresolved placeholders are to be ignored
Returns:
  the resolved String
Throws:
  `IllegalArgumentException` - if there is an unresolvable placeholder
See Also:
  - `PLACEHOLDER_PREFIX`
  - `and the "ignoreUnresolvablePlaceholders" flag is `false``