code: public static void replace(final String string, final String find, final String replacement, final Appendable out) throws IOException {
  		int pos = string.indexOf(find);
  		//System.out.println(string+": "+find+" at "+pos);
  		if (pos == -1) {
  			out.append(string);
  		} else {
  			int lastpos = 0;
  			final int findLen = find.length();
  			do {
  				out.append(string, lastpos, pos).append(replacement);
  				lastpos = pos + findLen;
  				pos = string.indexOf(find, lastpos);
  			} while (pos != -1);
  			int len = string.length();
  			if(lastpos<len) out.append(string, lastpos, len);
  		}
  	}
docs: Replaces all occurrences of a String with a String, appends the replacement
  to <code>out</code>.