Java String Ends With endsWithIgnoreCase(final String text, final String suffix)

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

Description

Tests if the string ends with the specified suffix.

License

Apache License

Parameter

Parameter Description
text the string to test.
suffix the suffix.

Return

true if the character sequence represented by the argument is a suffix of the character sequence represented by this object; false otherwise. Note that the result will be true if the suffix is the empty string or is equal to this String object as determined by the method. If the text or suffix argument is null false is returned.

Declaration

public static boolean endsWithIgnoreCase(final String text, final String suffix) 

Method Source Code

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

public class Main {
    /**/*  w  ww.j a v  a2s  .  com*/
     * Tests if the string ends with the specified suffix.
     *
     * @param   text     the string to test.
     * @param   suffix   the suffix.
     * @return  <code>true</code> if the character sequence represented by the
     *          argument is a suffix of the character sequence represented by
     *          this object; <code>false</code> otherwise. Note that the 
     *          result will be <code>true</code> if the suffix is the 
     *          empty string or is equal to this <code>String</code> object 
     *          as determined by the {@link #equals(Object)} method. If the text or 
     *          suffix argument is null <code>false</code> is returned.
     */
    public static boolean endsWithIgnoreCase(final String text, final String suffix) {
        if (text == null || suffix == null) {
            return false;
        }
        return text.regionMatches(true, text.length() - suffix.length(), suffix, 0, suffix.length());
    }
}

Related

  1. endsWithIgnoreCase(final String source, final String target)
  2. endsWithIgnoreCase(final String str, final String end)
  3. endsWithIgnoreCase(final String string, final String end)
  4. endsWithIgnoreCase(final String text, final String suffix)
  5. endsWithIgnoreCase(final String text, final String suffix)
  6. endsWithIgnoreCase(Object string, Object suffix)
  7. endsWithIgnoreCase(String a, String b)
  8. endsWithIgnoreCase(String baseString, String compareString)
  9. endsWithIgnoreCase(String haystack, String needle)