Java String Starts Wtih startsWithIgnoreCase(final String source, final String target)

Here you can find the source of startsWithIgnoreCase(final String source, final String target)

Description

Returns true if given source string start with target string ignore case sensitive; false otherwise.

License

Apache License

Parameter

Parameter Description
source string to be tested.
target string to be tested.

Return

true if given source string start with target string ignore case sensitive; false otherwise.

Declaration

public static boolean startsWithIgnoreCase(final String source, final String target) 

Method Source Code

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

public class Main {
    /**//  w ww .  j  av a 2  s  .  c  o  m
     * Returns true if given source string start with target string ignore case
     * sensitive; false otherwise.
     *
     * @param source string to be tested.
     * @param target string to be tested.
     * @return true if given source string start with target string ignore case
     *         sensitive; false otherwise.
     */
    public static boolean startsWithIgnoreCase(final String source, final String target) {

        if (source.startsWith(target)) {
            return true;
        }
        if (source.length() < target.length()) {
            return false;
        }
        return source.substring(0, target.length()).equalsIgnoreCase(target);
    }
}

Related

  1. startsWithIC(String s1, String... strings)
  2. startsWithIgnoreCase(final String base, final String start)
  3. startsWithIgnoreCase(final String haystack, final String needle)
  4. startsWithIgnoreCase(final String iFirst, final String iSecond)
  5. startsWithIgnoreCase(final String input, final String prefix)
  6. startsWithIgnoreCase(final String str, final String prefix)
  7. startsWithIgnoreCase(final String str, final String prefix)
  8. startsWithIgnoreCase(final String string, final String start)
  9. startsWithIgnoreCase(final String stringToCheck, final String prefix)