Java String Starts Wtih startsWithMultiple(String string, String... starts)

Here you can find the source of startsWithMultiple(String string, String... starts)

Description

Checks if the input string starts with any of the values.

License

Open Source License

Parameter

Parameter Description
string Input string.
starts Values to check.

Return

True if the input string starts with any of the given values. False if none of the values begin the input string.

Declaration

public static boolean startsWithMultiple(String string, String... starts) 

Method Source Code

//package com.java2s;
/*/* w  w w.  j  a v  a  2 s.  c o m*/
 * StBukkitLib
 * Copyright (C) 2014 Stealth2800 <stealth2800@stealthyone.com>
 * Website: <http://stealthyone.com/>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Checks if the input string starts with any of the values.
     *
     * @param string Input string.
     * @param starts Values to check.
     * @return True if the input string starts with any of the given values.
     *         False if none of the values begin the input string.
     */
    public static boolean startsWithMultiple(String string, String... starts) {
        for (String start : starts) {
            if (string.startsWith(start)) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. startsWithLetter(String str)
  2. startsWithLetterOrUnderscore(String value)
  3. startsWithLinuxRoot(String path)
  4. startsWithLowerCase(String text)
  5. startsWithLowerCaseChar(String s)
  6. startsWithName(String subject, String beginName)
  7. startsWithNoCase(String csValue, String csStart)
  8. startsWithOne(final String src, final String[] dest)
  9. startsWithOneOf(String source, boolean ignoreCase, String... values)