Java String Ends With endsWithIgnoreCase(final String base, final String end)

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

Description

Helper functions to query a strings end portion.

License

LGPL

Parameter

Parameter Description
base the base string.
end the ending text.

Return

true, if the string ends with the given ending text.

Declaration

public static boolean endsWithIgnoreCase(final String base, final String end) 

Method Source Code

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

public class Main {
    /**//ww w .jav  a2 s .  com
     * Helper functions to query a strings end portion. The comparison is case insensitive.
     *
     * @param base  the base string.
     * @param end  the ending text.
     *
     * @return true, if the string ends with the given ending text.
     */
    public static boolean endsWithIgnoreCase(final String base, final String end) {
        if (base.length() < end.length()) {
            return false;
        }
        return base.regionMatches(true, base.length() - end.length(), end, 0, end.length());
    }

    public static int length(String str) {
        if (str == null)
            return 0;
        return str.length();
    }
}

Related

  1. endsWithExtension(final String fileName, final String extension)
  2. endsWithFFD9(byte[] data)
  3. endsWithGaps(final byte[] aFrag, final int numEndGaps)
  4. endsWithIC(String a, String b)
  5. endsWithIC(String s1, String s2)
  6. endsWithIgnoreCase(final String base, final String end)
  7. endsWithIgnoreCase(final String haystack, final String needle)
  8. endsWithIgnoreCase(final String haystack, final String needle)
  9. endsWithIgnoreCase(final String input, final String suffix)