### String Interpolation with Default Lookups Source: https://github.com/apache/commons-text/blob/master/src/main/javadoc/overview.html Use StringSubstitutor.createInterpolator() to create an interpolator with default lookups. This example shows various lookup types including base64, constants, dates, environment variables, file content, and system properties. ```java final StringSubstitutor interpolator = StringSubstitutor.createInterpolator(); final String text = interpolator.replace( "[Base64 Decoder](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html#base64DecoderStringLookup()): ${base64Decoder:SGVsbG9Xb3JsZCE=}\n" + "[Base64 Encoder](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html#base64EncoderStringLookup()): ${base64Encoder:HelloWorld!}\n" + "[Java Constant](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html#constantStringLookup()): ${const:java.awt.event.KeyEvent.VK_ESCAPE}\n" + "[Date](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html#dateStringLookup()): ${date:yyyy-MM-dd}\n" + "[Environment Variable](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html#environmentVariableStringLookup()): ${env:USERNAME}\n" + "[File Content](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html#fileStringLookup(java.nio.file.Path...))(): ${file:UTF-8:src/test/resources/document.properties}\n" + "[Java](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html#javaPlatformStringLookup()): ${java:version}\n" + "[Local host](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html#localHostStringLookup()): ${localhost:canonical-name}\n" + "[Loopback address](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html#localHostStringLookup()): ${loopbackAddress:canonical-name}\n" + "[Properties File](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html#propertiesStringLookup(java.nio.file.Path...))(): ${properties:src/test/resources/document.properties::mykey}\n" + "[Resource Bundle](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html#resourceBundleStringLookup(java.lang.String))(): ${resourceBundle:org.apache.commons.text.example.testResourceBundleLookup:mykey}\n" + "[System Property](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html#systemPropertyStringLookup()): ${sys:user.dir}\n" + "[URL Decoder](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html#urlDecoderStringLookup()): ${urlDecoder:Hello%20World%21}\n" + "[URL Encoder](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html#urlEncoderStringLookup()): ${urlEncoder:Hello World!}\n" + "[XML Decoder](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html#xmlDecoderStringLookup()): ${xmlDecoder:}\n") ``` -------------------------------- ### Create Default String Substitutor (Commons Text >= 1.8) Source: https://github.com/apache/commons-text/blob/master/src/main/javadoc/overview.html Create a default, full-featured StringSubstitutor using the createInterpolator() method. This is the recommended approach for versions 1.8 and later. ```java org.apache.commons.text.StringSubstitutor.createInterpolator() ``` -------------------------------- ### Create Default String Substitutor (Commons Text < 1.8) Source: https://github.com/apache/commons-text/blob/master/src/main/javadoc/overview.html Instantiate a default StringSubstitutor using StringLookupFactory for versions prior to 1.8. This provides a full set of interpolation capabilities. ```java new StringSubstitutor(StringLookupFactory.INSTANCE.interpolatorStringLookup()) ``` -------------------------------- ### Replace System Properties in String Source: https://github.com/apache/commons-text/blob/master/src/main/javadoc/overview.html Use StringSubstitutor to replace Java System properties within a string. This is useful for dynamic configuration or templating. ```java StringSubstitutor.replaceSystemProperties("You are running with java.version = ${java.version} and os.name = ${os.name}."); ``` -------------------------------- ### Add Apache Commons Text Dependency Source: https://github.com/apache/commons-text/blob/master/README.md Include this XML snippet in your Maven project's pom.xml to add Apache Commons Text as a dependency. ```xml org.apache.commons commons-text 1.15.0 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.