Java String Starts Wtih startsWith(final String str, final String... prefixes)

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

Description

Nullpointer save version of String.startsWith.

License

Open Source License

Return

True, if the given string starts with one of the given prefixes, otherwise false.

Declaration

public static boolean startsWith(final String str, final String... prefixes) 

Method Source Code

//package com.java2s;
// ProjectForge is dual-licensed.

public class Main {
    /**//from  w  w w .  j ava  2  s.  co  m
     * Nullpointer save version of String.startsWith.
     * @return True, if the given string starts with one of the given prefixes, otherwise false.
     * @see String#startsWith(String)
     */
    public static boolean startsWith(final String str, final String... prefixes) {
        if (str == null || prefixes == null) {
            return false;
        }
        for (final String prefix : prefixes) {
            if (str.startsWith(prefix) == true) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. startsWith(final String s, final String[] prefixes)
  2. startsWith(final String searchString, final String crit)
  3. startsWith(final String source, final String prefix)
  4. startsWith(final String src, final String sub)
  5. startsWith(final String str, final char prefix)
  6. startsWith(String baseString, String compareString)
  7. startsWith(String check, String doesStartWith)
  8. startsWith(String cid1, String cid2)
  9. startsWith(String comparee, char comparant)