Java String Starts Wtih startsWithAny(String toMatch, String... startsWithAny)

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

Description

Checks if a given String starts with any of the given Strings

License

Apache License

Parameter

Parameter Description
toMatch a String to check for matches
startsWithAny a parameter

Return

true if the String starts with any of the given Strings

Declaration

public static boolean startsWithAny(String toMatch, String... startsWithAny) 

Method Source Code

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

public class Main {
    /**//from   w  w w  .  j  av a2  s.c  o  m
     * Checks if a given String starts with any of the given Strings
     * 
     * @param toMatch
     *          a String to check for matches
     * @param startsWithAny
     * @return true if the String starts with any of the given Strings
     */
    public static boolean startsWithAny(String toMatch, String... startsWithAny) {
        for (String s : startsWithAny) {
            return toMatch.startsWith(s);
        }
        return false;
    }
}

Related

  1. startsWithAny(String s, String... options)
  2. startsWithAny(String source, String[] checks)
  3. startsWithAny(String str, String... args)
  4. startsWithAny(String stringToMatch, String... stringToCheckEquals)
  5. startsWithAny(String text, String... prefixes)
  6. startsWithAnyCI(String string, String... prefixes)
  7. startsWithAnyCS(String str, String[] needles)
  8. startsWithAnyIgnoreCase(String s, String... options)
  9. startsWithAnyIgnoreCase(String string, String... searchStrings)