Android String Case Convert endsWithIgnoreCase(String source, String suffix)

Here you can find the source of endsWithIgnoreCase(String source, String suffix)

Description

Whether the given source string ends with the given suffix, ignoring case.

Declaration

public static boolean endsWithIgnoreCase(String source, String suffix) 

Method Source Code

//package com.java2s;
import android.text.TextUtils;

public class Main {
    /**/*from w  w w . j  av  a2 s  . c  o  m*/
     * Whether the given source string ends with the given suffix, ignoring case.
     */
    public static boolean endsWithIgnoreCase(String source, String suffix) {
        if (isEmpty(suffix))
            return true;
        if (isEmpty(source))
            return false;
        if (suffix.length() > source.length())
            return false;
        return source.substring(source.length() - suffix.length())
                .toLowerCase().endsWith(suffix.toLowerCase());
    }

    /**
     * Whether the given string is null or zero-length
     */
    public static boolean isEmpty(String text) {
        return TextUtils.isEmpty(text);
    }
}

Related

  1. toUpperCase(String src)
  2. flipCase(final String s)
  3. matchesIgnoreCase(String str, String query, int startingAt)
  4. lowerCase(String str)
  5. upperCase(String str)
  6. endsWithIgnoreCase(final String target1, final String target2)
  7. startsWithIgnoreCase(final String target1, final String target2)
  8. toTitleCase(String s)
  9. camelString(String str, boolean firstCharacterUppercase)