Skeleton { public static String replace(String a, String b, String c) { StringBuilder result = new StringBuilder(c.length()); int i = 0; int j = c.indexOf(a); while (j >= i) { result.append(c.substring(i, j)); result.append(b); i = j + a.length(); j = c.indexOf(a, i); } result.append(c.substring(i, c.length())); return result.toString(); } Skeleton(PrintWriter out); void emitNext(); static void makePrivate(); static void readSkelFile(File skeletonFile); static void readSkel(BufferedReader reader); static String replace(String a, String b, String c); static void readDefault(); static String[] line; }
@Test public void testReplace() { assertThat(Skeleton.replace("bla ", "blub", "bla blub bla ")).isEqualTo("blubblub blub"); }