Java String Ends With endsWithIC(String s1, String s2)

Here you can find the source of endsWithIC(String s1, String s2)

Description

Returns whether s1 ends with s2, ignoring case.

License

Open Source License

Declaration

public static boolean endsWithIC(String s1, String s2) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from www  .  java2 s . c o m
     * Returns whether s1 ends with s2, ignoring case.
     */
    public static boolean endsWithIC(String s1, String s2) {
        return s1 != null && s2 != null && s1.regionMatches(true, s1.length() - s2.length(), s2, 0, s2.length());
    }

    /**
     * Returns whether s1 ends with any of the given strings, ignoring case.
     */
    public static boolean endsWithIC(String s1, String... strings) {
        for (String string : strings)
            if (endsWithIC(s1, string))
                return true;
        return false;
    }

    /**
     * Returns the length of given string (supports null).
     */
    public static int length(CharSequence aString) {
        return aString == null ? 0 : aString.length();
    }
}

Related

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