Java String Ends With endsWithIgnoreCase(String str, String suffix)

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

Description

ends With Ignore Case

License

Mozilla Public License

Declaration

public static boolean endsWithIgnoreCase(String str, String suffix) 

Method Source Code

//package com.java2s;
//License from project: Mozilla Public License 

public class Main {
    public static boolean endsWithIgnoreCase(String str, String suffix) {
        return endsWith(str, suffix, true);
    }/*from  w  w  w . j  a v  a2s. co m*/

    public static boolean endsWith(String str, String suffix) {
        return endsWith(str, suffix, false);
    }

    private static boolean endsWith(String str, String suffix, boolean ignoreCase) {
        if (str == null || suffix == null) {
            return (str == null && suffix == null);
        }

        if (suffix.length() > str.length()) {
            return false;
        }

        int strOffset = str.length() - suffix.length();

        return str.regionMatches(ignoreCase, strOffset, suffix, 0, suffix.length());
    }

    public static int length(String str) {
        return str == null ? 0 : str.length();
    }
}

Related

  1. endsWithIgnoreCase(String s, String suffix)
  2. endsWithIgnoreCase(String s, String w)
  3. endsWithIgnoreCase(String seq, String suffix)
  4. endsWithIgnoreCase(String source, String eq)
  5. endsWithIgnoreCase(String str, String suffix)
  6. endsWithIgnoreCase(String str, String suffix)
  7. endsWithIgnoreCase(String str, String suffix)
  8. endsWithIgnoreCase(String str, String suffix)
  9. endsWithIgnoreCase(String str, String suffix)