StringUtilities { public static String stripSuffix(String string, String suffix) { int index = string.lastIndexOf(suffix); return index == -1 ? string : string.substring(0, index); }  static String escape(String source); static String escape(String source, char delimiter); static String unescape(String source); static String implode(String[] array, String sepString); static String implodeMultiline(List<String> lines); static String truncateSequencesIfNecessary(String text, int maxConsecutiveLength); static String stripSuffix(String string, String suffix); static String quote(Object object); static Set<String> split(String s);  }
@Test public void testStripSuffix() { assertThat(StringUtilities.stripSuffix("abc.def", ".def"), is("abc")); assertThat(StringUtilities.stripSuffix("abc.def", ""), is("abc.def")); assertThat(StringUtilities.stripSuffix("", ".def"), is("")); assertThat(StringUtilities.stripSuffix("", ""), is("")); }