Java String Ends With endsWithIgnoreCase(final String source, final String target)

Here you can find the source of endsWithIgnoreCase(final String source, final String target)

Description

Returns true if given source string end with target string ignore case sensitive; false otherwise.

License

Apache License

Parameter

Parameter Description
source string to be tested.
target string to be tested.

Return

true if given source string end with target string ignore case sensitive; false otherwise.

Declaration

public static boolean endsWithIgnoreCase(final String source, final String target) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from   w ww . j a v a  2  s  .  c  o  m*/
     * Returns true if given source string end with target string ignore case
     * sensitive; false otherwise.
     *
     * @param source string to be tested.
     * @param target string to be tested.
     * @return true if given source string end with target string ignore case
     *         sensitive; false otherwise.
     */
    public static boolean endsWithIgnoreCase(final String source, final String target) {

        if (source.endsWith(target)) {
            return true;
        }
        if (source.length() < target.length()) {
            return false;
        }
        return source.substring(source.length() - target.length()).equalsIgnoreCase(target);
    }
}

Related

  1. endsWithIgnoreCase(final String base, final String end)
  2. endsWithIgnoreCase(final String base, final String end)
  3. endsWithIgnoreCase(final String haystack, final String needle)
  4. endsWithIgnoreCase(final String haystack, final String needle)
  5. endsWithIgnoreCase(final String input, final String suffix)
  6. endsWithIgnoreCase(final String str, final String end)
  7. endsWithIgnoreCase(final String string, final String end)
  8. endsWithIgnoreCase(final String text, final String suffix)
  9. endsWithIgnoreCase(final String text, final String suffix)