StringUtil { public static String suffixAfterLastSlash(String uri) { int finalSlashIndex = uri.lastIndexOf('/'); return finalSlashIndex == -1 ? uri : uri.substring(finalSlashIndex + 1); } protected  StringUtil(); static String[] splitAtLastSlash(String uri); static String suffixAfterLastSlash(String uri); static String escapeDoubleQuotes(String s);  }
@Test public void suffixAfterLastSlashTrimsEverythingBeforeTheLastSlash() { String randomWord = randomAlphanumeric(20); assertThat(StringUtil.suffixAfterLastSlash(randomWord)) .isEqualTo(StringUtil.suffixAfterLastSlash("/" + randomWord)) .isEqualTo(StringUtil.suffixAfterLastSlash(randomAlphanumeric(20) + "/" + randomWord)) .isEqualTo(randomWord); assertThat(StringUtil.suffixAfterLastSlash("")) .isEmpty(); assertThatNullPointerException().isThrownBy(() -> StringUtil.suffixAfterLastSlash(null)); }