public static String replace(String base, char c, String str) { final int len = base.length() - 1; int pos; while ((pos = base.indexOf(c)) > -1) { if (pos == 0) { final String after = base.substring(1); base = str + after; } else if (pos == len) { final String before = base.substring(0, pos); base = before + str; } else { final String before = base.substring(0, pos); final String after = base.substring(pos+1); base = before + str + after; } } return base;
public static String replace(String base, char ch, String str) { return (base.indexOf(ch) < 0) ? base : replace(base, String.valueOf(ch), new String[] { str });
    public static String replace(String base, char c, String str) {	final int len = base.length() - 1;	int pos;	while ((pos = base.indexOf(c)) > -1) {	    if (pos == 0) {		final String after = base.substring(1);		base = str + after;	    }	    else if (pos == len) {		final String before = base.substring(0, pos);		base = before + str;	    }	    else {		final String before = base.substring(0, pos);		final String after = base.substring(pos+1);		base = before + str + after;	    }	}	return base;    }