Java String Starts Wtih startsWith(String target, String... prefixes)

Here you can find the source of startsWith(String target, String... prefixes)

Description

Returns whether the given target string starts with one of the given prefixes.

License

Open Source License

Declaration

public static boolean startsWith(String target, String... prefixes) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2007, 2008 Tran Nam Quang.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from  www.java 2 s .c  o m*/
 *    Tran Nam Quang - initial API and implementation
 *******************************************************************************/

public class Main {
    /**
     * Returns whether the given target string starts with one of the given prefixes.
     */
    public static boolean startsWith(String target, String... prefixes) {
        for (String prefix : prefixes)
            if (target.startsWith(prefix))
                return true;
        return false;
    }
}

Related

  1. startsWith(String str, String start, boolean caseSensitive)
  2. startsWith(String str1Raw, String str2Raw)
  3. startsWith(String string, char... ca)
  4. startsWith(String string, String prefix)
  5. startsWith(String string, StringBuffer prefix, int toffset)
  6. startsWith(String text, String prefix, int toffset)
  7. startsWith(String toTest, String[] possibilities)
  8. startsWith(String value, String startsWith)
  9. startsWith(String[] array, String obj)