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

booleanendsWithIgnoreCase(String p_sStr, String p_sSubStr)
Same as String#endsWith(String) , but ignoring case
if (p_sSubStr.length() > p_sStr.length())
    return false;
int nSubStrLen = p_sSubStr.length();
int nStrLen = p_sStr.length();
int nIdx = 1;
for (int i = nSubStrLen - 1; i >= 0; i--) {
    char cSubStr = p_sSubStr.charAt(i);
    char cStr = p_sStr.charAt(nStrLen - nIdx);
...
booleanendsWithIgnoreCase(String s, String suffix)
Check if a String ends with a specified suffix, ignoring case
if (s == null || suffix == null) {
    return (s == null && suffix == null);
if (suffix.length() > s.length()) {
    return false;
return s.regionMatches(true, s.length() - suffix.length(), suffix, 0, suffix.length());
booleanendsWithIgnoreCase(String s, String suffix)
ends With Ignore Case
return s.regionMatches(true, s.length() - suffix.length(), suffix, 0, suffix.length());
booleanendsWithIgnoreCase(String s, String w)
ends With Ignore Case
if (w == null)
    return true;
int sl = s.length();
int wl = w.length();
if (s == null || sl < wl)
    return false;
for (int i = wl; i-- > 0;) {
    char c1 = s.charAt(--sl);
...
booleanendsWithIgnoreCase(String seq, String suffix)
Tests if this string sequence ends with the specified suffix.
return seq.toLowerCase().endsWith(suffix.toLowerCase());
booleanendsWithIgnoreCase(String source, String eq)
ends With Ignore Case
int temp = eq.length();
if (eq.length() > source.length()) {
    return false;
return source.substring(source.length() - temp).equalsIgnoreCase(eq);
booleanendsWithIgnoreCase(String str, String suffix)
ends With Ignore Case
final int stringLength = str.length();
final int suffixLength = suffix.length();
return stringLength >= suffixLength
        && str.regionMatches(true, stringLength - suffixLength, suffix, 0, suffixLength);
booleanendsWithIgnoreCase(String str, String suffix)
ends With Ignore Case
return endsWith(str, suffix, true);
booleanendsWithIgnoreCase(String str, String suffix)
Test if the given String ends with the specified suffix, ignoring upper/lower case.
return (str != null && suffix != null && str.length() >= suffix.length()
        && str.regionMatches(true, str.length() - suffix.length(), suffix, 0, suffix.length()));
booleanendsWithIgnoreCase(String str, String suffix)
 StringUtilities.endsWithIgnoreCase(null, null)      = true StringUtilities.endsWithIgnoreCase(null, "def")     = false StringUtilities.endsWithIgnoreCase("abcdef", null)  = false StringUtilities.endsWithIgnoreCase("abcdef", "def") = true StringUtilities.endsWithIgnoreCase("ABCDEF", "def") = true StringUtilities.endsWithIgnoreCase("ABCDEF", "cde") = false 
return endsWith(str, suffix, true);