Ejemplo n.º 1
0
 private static void replace(String source, String pattern, String replace, StringBuffer builder) {
   int pos = 0;
   int pl = pattern.length();
   builder.delete(0, builder.length());
   while (pos < source.length()) {
     int np = source.indexOf(pattern, pos);
     if (np == -1) break;
     builder.append(source.substring(pos, np));
     builder.append(replace);
     pos = np + pl;
   }
   builder.append(source.substring(pos));
 }