@Test public void testRemoveLastInstanceOf() { String testString = "1,2,3,4,5,6,7,"; String expected = "1,2,3,4,5,6,7"; assertEquals(expected, removeTrailing(testString, ",")); assertEquals(expected, removeTrailing(expected, ",")); assertEquals("21", removeTrailing("21,", ",")); assertEquals("21", removeTrailing("21" + Separators.LEVEL_SEPARATOR, Separators.LEVEL_SEPARATOR)); }
public static String removeTrailing(String input, String toRemove) { if (isNullOrEmpty(input) || (input.length() - toRemove.length() != input.lastIndexOf(toRemove))) { return input; } return input.substring(0, input.length() - toRemove.length()); }
StringUtils { public static String removeTrailing(String input, String toRemove) { if (isNullOrEmpty(input) || (input.length() - toRemove.length() != input.lastIndexOf(toRemove))) { return input; } return input.substring(0, input.length() - toRemove.length()); } }
StringUtils { public static String removeTrailing(String input, String toRemove) { if (isNullOrEmpty(input) || (input.length() - toRemove.length() != input.lastIndexOf(toRemove))) { return input; } return input.substring(0, input.length() - toRemove.length()); } StringUtils(); }
StringUtils { public static String removeTrailing(String input, String toRemove) { if (isNullOrEmpty(input) || (input.length() - toRemove.length() != input.lastIndexOf(toRemove))) { return input; } return input.substring(0, input.length() - toRemove.length()); } StringUtils(); static boolean isNullOrEmpty(String input); static String removeTrailing(String input, String toRemove); }
StringUtils { public static String removeTrailing(String input, String toRemove) { if (isNullOrEmpty(input) || (input.length() - toRemove.length() != input.lastIndexOf(toRemove))) { return input; } return input.substring(0, input.length() - toRemove.length()); } StringUtils(); static boolean isNullOrEmpty(String input); static String removeTrailing(String input, String toRemove);  }