Java String Starts Wtih startsWithIgnoreCase(final String str, final String prefix)

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

Description

starts With Ignore Case

License

Apache License

Declaration

public static boolean startsWithIgnoreCase(final String str, final String prefix) 

Method Source Code

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

public class Main {
    public static boolean startsWithIgnoreCase(final String str, final String prefix) {
        if (str == null || prefix == null) {
            return false;
        }//from  ww  w . ja  v  a  2  s .  c  om
        if (str.startsWith(prefix)) {
            return true;
        }
        if (str.length() < prefix.length()) {
            return false;
        }
        final String lcStr = str.substring(0, prefix.length()).toLowerCase();
        final String lcPrefix = prefix.toLowerCase();
        return lcStr.equals(lcPrefix);
    }
}

Related

  1. startsWithIgnoreCase(final String haystack, final String needle)
  2. startsWithIgnoreCase(final String iFirst, final String iSecond)
  3. startsWithIgnoreCase(final String input, final String prefix)
  4. startsWithIgnoreCase(final String source, final String target)
  5. startsWithIgnoreCase(final String str, final String prefix)
  6. startsWithIgnoreCase(final String string, final String start)
  7. startsWithIgnoreCase(final String stringToCheck, final String prefix)
  8. startsWithIgnoreCase(final String target1, final String target2)
  9. startsWithIgnoreCase(final String text, final String prefix)