Java String Starts Wtih startsWithOneOf(String string, String... prefixes)

Here you can find the source of startsWithOneOf(String string, String... prefixes)

Description

Returns true if the given string starts with one of the given prefixes.

License

Apache License

Parameter

Parameter Description
string The object to be checked if it starts with one of the given prefixes.
prefixes The argument list of prefixes to be checked

Return

true if the given string starts with one of the given prefixes.

Declaration

public static boolean startsWithOneOf(String string, String... prefixes) 

Method Source Code

//package com.java2s;
/*//from w  w  w .j a va  2 s. c o m
 * Copyright 2013 OmniFaces.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */

public class Main {
    /**
     * Returns <code>true</code> if the given string starts with one of the given prefixes.
     * @param string The object to be checked if it starts with one of the given prefixes.
     * @param prefixes The argument list of prefixes to be checked
     * @return <code>true</code> if the given string starts with one of the given prefixes.
     * @since 1.4
     */
    public static boolean startsWithOneOf(String string, String... prefixes) {
        for (String prefix : prefixes) {
            if (string.startsWith(prefix)) {
                return true;
            }
        }

        return false;
    }
}

Related

  1. startsWithName(String subject, String beginName)
  2. startsWithNoCase(String csValue, String csStart)
  3. startsWithOne(final String src, final String[] dest)
  4. startsWithOneOf(String source, boolean ignoreCase, String... values)
  5. startsWithOneOf(String str, String... strs)
  6. startsWithOrMatches(String s1, String s2)
  7. startsWithPattern(String value, String matchingPatterns)
  8. startsWithPhraseSeparator(char[] token)
  9. startsWithPrefix(final String methodName, final String prefix, final int prefixLength)