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

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

Description

Returns true if the string to check ends with the specified suffix; this check is case-insensitive.

License

Apache License

Parameter

Parameter Description
toCheck the string to check to see if it ends with the suffix
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

Declaration

public static boolean endsWithIgnoreCase(String toCheck, String suffix) 

Method Source Code

//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;
    }
}

Related

  1. endsWithIgnoreCase(String str, String suffix)
  2. endsWithIgnoreCase(String str, String suffix)
  3. endsWithIgnoreCase(String string, String suffix)
  4. endsWithIgnoreCase(String target1, String target2)
  5. endsWithIgnoreCase(String text, String suffix)
  6. endsWithIgnSpace(String s, String ending)
  7. endsWithIllegalWindowsChar(String filename)
  8. endsWithIndex(String[] suffixes, String propertyName)
  9. endsWithLineSeparator(final CharSequence msg)