StringUtil { @Deprecated public static String replaceString(final String original, final String oldString, final String newString) { int index = original.indexOf(oldString); if (index < 0) { return original; } else { final String replace = newString == null ? "" : newString; final StringBuilder buf = new StringBuilder(Math.max(16, original.length() + replace.length())); int last = 0; while (index != -1) { buf.append(original.substring(last, index)); buf.append(replace); last = index + oldString.length(); index = original.indexOf(oldString, last); } buf.append(original.substring(last)); return buf.toString(); } } private  StringUtil(); static int lineNumberAt(CharSequence charSeq, int offsetInclusive); static int columnNumberAt(CharSequence charSeq, final int offsetInclusive); static String percentageString(double val, int numDecimals); @Deprecated static boolean startsWithAny(String text, String... prefixes); static boolean isAnyOf(String text, String... tests); static String withoutPrefixes(String text, String... prefixes); @Deprecated static boolean isNotEmpty(String value); @Deprecated static boolean isEmpty(String value); @Deprecated static boolean isMissing(String value); @Deprecated static boolean areSemanticEquals(String a, String b); @Deprecated static String replaceString(final String original, final String oldString, final String newString); @Deprecated static void appendXmlEscaped(StringBuilder buf, String src, boolean supportUTF8); static String removedInvalidXml10Characters(String text); static String escapeWhitespace(Object o); @Deprecated static String replaceString(final String original, char oldChar, final String newString); @Deprecated static String[] substringsOf(String source, char delimiter); @Deprecated static String[] substringsOf(String str, String separator); @Deprecated static void asStringOn(StringBuffer sb, Iterator<?> iter, String separator); @Deprecated static void asStringOn(StringBuilder sb, Object[] items, String separator); static int maxCommonLeadingWhitespaceForAll(String[] strings); static int lengthOfShortestIn(String[] strings); static String[] trimStartOn(String[] strings, int trimDepth); @Deprecated static String lpad(String s, int length); static boolean isSame(String s1, String s2, boolean trim, boolean ignoreCase,
                                 boolean standardizeWhitespace); static String asString(Object[] items, String separator); static String[] getEmptyStrings(); static String toCamelCase(String name); static String toCamelCase(String name, boolean forceLowerCase); static String escapeJava(String str);  }
@Test public void testReplaceWithOneChar() { assertEquals("faa", StringUtil.replaceString("foo", 'o', "a")); }
@Test public void testReplaceWithMultipleChars() { assertEquals("faaaa", StringUtil.replaceString("foo", 'o', "aa")); }
@Test public void testReplaceStringWithString() { assertEquals("foo]]&gt;bar", StringUtil.replaceString("foo]]>bar", "]]>", "]]&gt;")); }
@Test public void testReplaceStringWithString2() { assertEquals("replaceString didn't work with a >", "foobar", StringUtil.replaceString("foobar", "]]>", "]]&gt;")); }
@Test public void testReplaceWithNull() { assertEquals("replaceString didn't work with a char", "f", StringUtil.replaceString("foo", 'o', null)); }