Here you can find the source of endsWithIgnoreCase(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
public static boolean endsWithIgnoreCase(String str, String suffix)
//package com.java2s; //License from project: Apache License public class Main { /**/*w ww . j a va2s .c o m*/ * <pre> * 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 * </pre> */ public static boolean endsWithIgnoreCase(String str, String suffix) { return endsWith(str, suffix, true); } /** * <pre> * 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 * </pre> */ 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()); } }