Java Utililty Methods String Substritute

List of utility methods to do String Substritute

Description

The list of methods to do String Substritute are organized into topic(s).

Method

StringsubstituteMarkers(String sql, String marker, Object substitution)
substitute Markers
return sql.replace(marker, renderValue(substitution));
StringsubstituteNull(String value, String substitution)
substitute Null
return (value != null ? value : substitution);
StringsubstitutePropertyWithIn(String propertyName, String replacementString, String evaluatedString)
Substitute property with in.
replacementString = replacementString.replace("\\", "\\\\");
return evaluatedString.replaceAll("\\$\\{" + propertyName + "\\}", replacementString);
StringsubstituteSelectedCharacters(String text, boolean skip)
Substitutes the selected characters with entities.
if (text != null) {
    StringBuffer newText = new StringBuffer();
    for (int i = 0; i < text.length(); i++) {
        char character = text.charAt(i);
        if (character == '<') {
            if (skip)
                newText.append("&lt;");
            else
...
StringsubstituteSpaces(String originalPath)
substituteSpaces substitutes %20 in spaces in a path (MacOS X)
if (originalPath == null)
    return "";
StringBuffer s = new StringBuffer(originalPath);
for (int i = 0; i < s.length(); i++) {
    if (s.charAt(i) == ' ') {
        s.setCharAt(i, '0');
        s.insert(i++, '%');
        s.insert(i++, '2');
...
StringsubstituteSubString(String input, String find, String replace)
Replace substrings of one string with another string and return altered string.
int find_length = find.length();
int replace_length = replace.length();
StringBuffer output = new StringBuffer(input);
int index = input.indexOf(find);
int outputOffset = 0;
while (index > -1) {
    output.replace(index + outputOffset, index + outputOffset + find_length, replace);
    outputOffset = outputOffset + (replace_length - find_length);
...
StringsubstituteSymbol(String text, String symbol, String value)
String substitution routine.
StringBuffer buffer;
while (text.indexOf(symbol) >= 0) {
    buffer = new StringBuffer(text);
    buffer.replace(text.indexOf(symbol), text.indexOf(symbol) + symbol.length(), value);
    text = buffer.toString();
return text;
StringsubstituteSymbol(String text, String symbol, String value)
substitute Symbol
StringBuffer buffer;
while (text.indexOf(symbol) >= 0) {
    buffer = new StringBuffer(text);
    buffer.replace(text.indexOf(symbol), text.indexOf(symbol) + symbol.length(), value);
    text = buffer.toString();
return text;
StringsubstituteTabsAndNewLinesWithSpaces(String str)
substitute Tabs And New Lines With Spaces
return str.replaceAll("\\t", " ").replaceAll("\\n", " ");
StringsubstituteText(String text, String token, String substitute)
Renders a string based on text where any occurence of token is replaced by substitute.
int index;
if (token == null || substitute == null || (index = text.indexOf(token)) < 0)
    return text;
while (index > -1) {
    text = text.substring(0, index) + substitute + text.substring(index + token.length());
    index = text.indexOf(token);
return text;
...