Java String Starts Wtih startsWithAny(String _str, String... _startStrings)

Here you can find the source of startsWithAny(String _str, String... _startStrings)

Description

Checks if given String starts with any of the other given parameters.

License

Open Source License

Parameter

Parameter Description
_str string to check
_startStrings start strings to compare

Return

true if any match, false otherwise

Declaration

public static boolean startsWithAny(String _str, String... _startStrings) 

Method Source Code

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

public class Main {
    /**//from www . j a  v  a2 s.c  o  m
     * Checks if given String starts with any of the other given parameters.
     *
     * @param _str string to check
     * @param _startStrings start strings to compare
     * @return true if any match, false otherwise
     */
    public static boolean startsWithAny(String _str, String... _startStrings) {
        if (_str == null || _startStrings == null || _startStrings.length == 0) {
            return false;
        }

        for (String start : _startStrings) {
            if (_str.startsWith(start)) {
                return true;
            }
        }

        return false;
    }
}

Related

  1. startsWith(StringBuilder sb, String prefix)
  2. startsWith(T[] arr, T[] prefix)
  3. startsWith4(String string, int startIndex, int char1, int char2, int char3, int char4)
  4. startsWithAcronym(String word)
  5. startsWithAndHasMore(String input, String toStartWith)
  6. startsWithAny(String s, String... options)
  7. startsWithAny(String source, String[] checks)
  8. startsWithAny(String str, String... args)
  9. startsWithAny(String stringToMatch, String... stringToCheckEquals)