Java Utililty Methods String Ends With

List of utility methods to do String Ends With

Description

The list of methods to do String Ends With are organized into topic(s).

Method

booleanendsWith(String str, String end, boolean caseSensitive)
ends With
if (str == null || end == null) {
    return (str == null && end == null);
if (end.length() > str.length()) {
    return false;
int offset = str.length() - end.length();
return str.regionMatches(caseSensitive, offset, end, 0, end.length());
...
booleanendsWith(String str, String mark)
ends With
return startsWith(str, mark, str.length() - mark.length());
booleanendsWith(String str, String suffix)

Check if a String ends with a specified suffix.

nulls are handled without exceptions.

return endsWith(str, suffix, false);
booleanendsWith(String str, String suffix)
 StringUtilities.endsWith(null, null)      = true StringUtilities.endsWith(null, "def")     = false StringUtilities.endsWith("abcdef", null)  = false StringUtilities.endsWith("abcdef", "def") = true StringUtilities.endsWith("ABCDEF", "def") = false StringUtilities.endsWith("ABCDEF", "cde") = false 
return endsWith(str, suffix, false);
booleanendsWith(String str, String suffix, boolean ignoreCase)
ends With
if (str == null || suffix == null)
    return str == null && suffix == null;
int suffixLength;
int length;
if ((suffixLength = suffix.length()) > (length = str.length()))
    return false;
return str.regionMatches(ignoreCase, length - suffixLength, suffix, 0, suffixLength);
booleanEndsWith(String str, String suffix, int strStartPos)
Ends With
if (str == null) {
    throw new NullPointerException("str");
if (suffix == null) {
    throw new NullPointerException("suffix");
if (strStartPos < 0) {
    throw new IllegalArgumentException("strStartPos (" + strStartPos + ") is less than " + "0");
...
booleanendsWith(String string, char character)
ends With
return lastChar(string) == character;
booleanendsWith(String string, String... end)
ends With
for (String s : end) {
    if (string.endsWith(s))
        return true;
return false;
booleanendsWith(String string, String... endsWithText)
return true if the string endsWith in any endsWithText
if (endsWithText != null) {
    for (String endWithText : endsWithText) {
        if (string.endsWith(endWithText)) {
            return true;
return false;
...
booleanendsWith(String value, String[] suffixes)
ends With
if (value != null && suffixes != null) {
    for (String suffix : suffixes) {
        if (value.endsWith(suffix)) {
            return true;
return false;
...