01: package org.acm.seguin.pmd.util;
02:
03: public class StringUtil {
04: public static String replaceString(String d, char oldChar,
05: String newString) {
06: StringBuffer desc = new StringBuffer();
07: int index = d.indexOf(oldChar);
08: int last = 0;
09: while (index != -1) {
10: desc.append(d.substring(last, index));
11: desc.append(newString);
12: last = index + 1;
13: index = d.indexOf(oldChar, last);
14: }
15: desc.append(d.substring(last));
16: return desc.toString();
17: }
18:
19: public static String replaceString(String inputString,
20: String oldString, String newString) {
21: StringBuffer desc = new StringBuffer();
22: int index = inputString.indexOf(oldString);
23: int last = 0;
24: while (index != -1) {
25: desc.append(inputString.substring(last, index));
26: desc.append(newString);
27: last = index + oldString.length();
28: index = inputString.indexOf(oldString, last);
29: }
30: desc.append(inputString.substring(last));
31: return desc.toString();
32: }
33:
34: }
|