StringUtil { public static String substringAfterLast(String text, char separator) { if (isEmpty(text)) { return text; } int cPos = text.lastIndexOf(separator); if (cPos < 0) { return ""; } return text.substring(cPos + 1); }  static String collapsePathDots(String path); static boolean isNotBlank(String text); static boolean isBlank(String text); static boolean isEmpty(String text); static boolean endsWithIgnoreCase(String source, String suffix); static String defaultIfNull(String text); static String defaultIfNull(String text, String defaultValue); static boolean equals(String text1, String text2); static String toString(Object... keyValues); static int hashCode(String... values); static String substringBefore(String text, char separator); static String substringBeforeLast(String text, char separator); static String substringAfterLast(String text, char separator); static String substringAfter(String text, char c);  }
@Test public void testSubstringAfterLast() { Object[] testData = new Object[] { "", ' ', "", "", 'X', "", "fox", 'f', "ox", "foo.bar", 'b', "ar", "aXbXc", 'X', "c", }; for (int i = 0; i < testData.length; i += 3) { String actualResult = StringUtil.substringAfterLast( (String) testData[i], (Character) testData[i + 1]); String expectedResult = (String) testData[i + 2]; assertEquals( (i / 3) + " : " + testData[i] + ", " + testData[i + 1], expectedResult, actualResult); } }