Java String Substritute substituteBlanks(String s, String subst)

Here you can find the source of substituteBlanks(String s, String subst)

Description

substitute Blanks

License

Open Source License

Declaration

public static String substituteBlanks(String s, String subst) 

Method Source Code

//package com.java2s;
// This software is released under the 2-clause BSD license.

public class Main {
    public static String substituteBlanks(String s, String subst) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != ' ') {
                sb.append(s.charAt(i));//from  www.  j  a va 2 s  .  c o  m
            } else {
                sb.append(subst);
            }
        }
        return sb.toString();
    }
}

Related

  1. substitute(String string, String pattern, String replacement)
  2. substitute(String strSource, String strValue, String strBookmark)
  3. substitute(String template, String[] values)
  4. substitute(String txt, String pattern, String sub)
  5. substituteAll(String regexp, String subst, String target)
  6. substituteCommandLine(String[] parsedCommandLine, String file1Name, String file2Name, String display1, String display2)
  7. substituteEnvironmentVariables(String str, String prefix, String suffix)
  8. substituteHex(String aString)
  9. substituteInvalidChars(String str)