Java String Ends With endsWithAny(String string, String searchStrings[])

Here you can find the source of endsWithAny(String string, String searchStrings[])

Description

ends With Any

License

Open Source License

Declaration

public static boolean endsWithAny(String string, String searchStrings[]) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static boolean endsWithAny(String string, String searchStrings[]) {
        if (isEmpty(string) || (searchStrings == null || searchStrings.length < 1))
            return false;
        for (int i = 0; i < searchStrings.length; i++) {
            String searchString = searchStrings[i];
            if (endsWith(string, searchString))
                return true;
        }/*from w  ww.  j a v  a  2  s  .  com*/
        return false;
    }

    public static boolean isEmpty(CharSequence str) {
        return str == null || str.length() == 0;
    }

    public static boolean endsWith(String str, String suffix) {
        return endsWith(str, suffix, false);
    }

    private static boolean endsWith(String str, String suffix, boolean ignoreCase) {
        if (str == null || suffix == null) {
            return str == null && suffix == null;
        }
        if (suffix.length() > str.length()) {
            return false;
        }
        int strOffset = str.length() - suffix.length();
        return str.regionMatches(ignoreCase, strOffset, suffix, 0, suffix.length());
    }

    /**
     * Gets a String's length or <code>0</code> if the String is
     * <code>null</code>.
     *
     * @param str
     *            a String or <code>null</code>
     * @return String length or <code>0</code> if the String is
     *         <code>null</code>.
     * @since 2.4
     */
    public static int length(String str) {
        return str == null ? 0 : str.length();
    }
}

Related

  1. endsWith(StringBuilder sb, String s)
  2. endsWith(StringBuilder sb, String suffix)
  3. endsWith3(String string, int char1, int char2, int char3)
  4. endsWithAny(final byte[] str, int startIndex, int endIndex, final byte... chars)
  5. endsWithAny(String str, String... args)
  6. endsWithAny(String stringToMatch, String... stringToCheckEquals)
  7. endsWithAnyCI(String string, String... suffixes)
  8. endsWithAnyIC(String str, String[] needles)
  9. endsWithBackslash(final String s)