Here you can find the source of substituteBlanks(String s, String subst)
public static String substituteBlanks(String s, String subst)
//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(); } }