Here you can find the source of endsWithIgnoreCase(String toCheck, String suffix)
Parameter | Description |
---|---|
toCheck | the string to check to see if it ends with the suffix |
suffix | what the string to check should end with |
public static boolean endsWithIgnoreCase(String toCheck, String suffix)
//package com.java2s; /* Copyright 2009 Jeremy Chone - Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 *//*from ww w. jav a2 s . c o m*/ public class Main { /** * Returns true if the string to check ends with the specified suffix; this check is case-insensitive. If both * strings are null, then true is returned. Otherwise, <var>toCheck</var> must end with <var>suffix</var>, * disregarding case. * * @param toCheck * the string to check to see if it ends with the suffix * @param suffix * what the string to check should end with * @return true the string to check ends with the suffix without regard to case, or if both strings are null */ public static boolean endsWithIgnoreCase(String toCheck, String suffix) { boolean endsWith; if (toCheck == suffix) { endsWith = true; } else if (toCheck == null || suffix == null) { endsWith = false; } else { // toCheck and suffix are both non-null toCheck = toCheck.toLowerCase(); suffix = suffix.toLowerCase(); endsWith = toCheck.endsWith(suffix); } return endsWith; } }