Java String Ends With endsWithIgnoreCase(String input, String... suffixes)

Here you can find the source of endsWithIgnoreCase(String input, String... suffixes)

Description

Tests if this string ends with any of the given suffixes, ignoring the case sensitive.

License

Open Source License

Parameter

Parameter Description
input the input string to test
suffixes the list of suffixes

Return

true if the input string is a prefix; false otherwise.

Declaration

public static boolean endsWithIgnoreCase(String input, String... suffixes) 

Method Source Code

//package com.java2s;
//License from project: GNU General Public License 

public class Main {
    /**/*from   w  w  w.  jav a2 s. c  o m*/
     * Tests if this string ends with any of the given suffixes, ignoring the case sensitive.
     *
     * @param input the input string to test
     * @param suffixes the list of suffixes
     * @return {@code true} if the input string is a prefix; {@code false} otherwise.
     */
    public static boolean endsWithIgnoreCase(String input, String... suffixes) {
        boolean found = true;
        String lowerInput = input.toLowerCase();
        if (suffixes != null && suffixes.length > 0) {
            for (String suffix : suffixes) {
                found = lowerInput.endsWith(suffix.toLowerCase());
                if (found)
                    break;
            }
        }
        return found;
    }
}

Related

  1. endsWithIgnoreCase(Object string, Object suffix)
  2. endsWithIgnoreCase(String a, String b)
  3. endsWithIgnoreCase(String baseString, String compareString)
  4. endsWithIgnoreCase(String haystack, String needle)
  5. endsWithIgnoreCase(String input, String suffix)
  6. endsWithIgnoreCase(String name, Iterable patterns)
  7. endsWithIgnoreCase(String p_sStr, String p_sSubStr)
  8. endsWithIgnoreCase(String s, String suffix)
  9. endsWithIgnoreCase(String s, String suffix)