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

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

Description

Checks if the given String ends with the given suffix, ignoring case.

License

Open Source License

Parameter

Parameter Description
str The String to check.
suffix The suffix to check the String for.

Return

True if the given String ends with the given suffix, otherwise false.

Declaration

public static boolean endsWithIgnoreCase(String str, String suffix) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/* w w  w .  j  av a2  s.  c  o m*/
     * Checks if the given String ends with the given suffix, ignoring case.
     * 
     * @param str The String to check.
     * @param suffix The suffix to check the String for.
     * 
     * @return True if the given String ends with the given suffix, otherwise false.
     */
    public static boolean endsWithIgnoreCase(String str, String suffix) {
        if (str == null)
            throw new IllegalArgumentException("Parameter 'str' cannot be null!");
        if (suffix == null)
            throw new IllegalArgumentException("Parameter 'suffix' cannot be null!");

        if (str.length() < suffix.length())
            return false;

        String ending = str.substring(str.length() - suffix.length());

        return ending.equalsIgnoreCase(suffix);
    }
}

Related

  1. endsWithIgnoreCase(String source, String eq)
  2. endsWithIgnoreCase(String str, String suffix)
  3. endsWithIgnoreCase(String str, String suffix)
  4. endsWithIgnoreCase(String str, String suffix)
  5. endsWithIgnoreCase(String str, String suffix)
  6. endsWithIgnoreCase(String str, String suffix)
  7. endsWithIgnoreCase(String str, String suffix)
  8. endsWithIgnoreCase(String string, String suffix)
  9. endsWithIgnoreCase(String target1, String target2)