public static String replaceAllChars(String source, char search, String replace) {
        int indexOf = source.indexOf(search);
        if (indexOf == -1) {
            return source;
        }

        int offset = 0;
        char[] chars = source.toCharArray();
        StringBuilder sb = new StringBuilder(source.length() + 20);
        while (indexOf != -1) {
            sb.append(chars, offset, indexOf - offset);
            sb.append(replace);
            offset = indexOf + 1;
            indexOf = source.indexOf(search, offset);
        }
        sb.append(chars, offset, chars.length - offset);

        return sb.toString();
    }
@Test
    public void testreplaceAllChars() {
        assertEquals("", JOrphanUtils.replaceAllChars("", ' ', "+"));
        assertEquals("source", JOrphanUtils.replaceAllChars("source", ' ', "+"));
        assertEquals("so+rce", JOrphanUtils.replaceAllChars("source", 'u', "+"));
        assertEquals("+so+urc+", JOrphanUtils.replaceAllChars("esoeurce", 'e', "+"));
        assertEquals("AZAZsoAZurcAZ", JOrphanUtils.replaceAllChars("eesoeurce", 'e', "AZ"));
        assertEquals("A+B++C+", JOrphanUtils.replaceAllChars("A B  C ", ' ', "+"));
        assertEquals("A%20B%20%20C%20", JOrphanUtils.replaceAllChars("A B  C ", ' ', "%20"));
    }