Java String Start With startWithIgnoreCase(CharSequence str, CharSequence prefix)

Here you can find the source of startWithIgnoreCase(CharSequence str, CharSequence prefix)

Description

start With Ignore Case

License

Apache License

Declaration

public static boolean startWithIgnoreCase(CharSequence str, CharSequence prefix) 

Method Source Code

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

public class Main {

    public static boolean startWithIgnoreCase(CharSequence str, CharSequence prefix) {
        return startWith(str, prefix, true);
    }//w w  w.  j  av  a2 s . c o  m

    public static boolean startWith(CharSequence str, CharSequence prefix, boolean isIgnoreCase) {
        if (null == str || null == prefix) {
            if (null == str && null == prefix) {
                return true;
            }
            return false;
        }

        if (isIgnoreCase) {
            return str.toString().toLowerCase().startsWith(prefix.toString().toLowerCase());
        } else {
            return str.toString().startsWith(prefix.toString());
        }
    }

    public static boolean startWith(CharSequence str, char c) {
        return c == str.charAt(0);
    }

    public static boolean startWith(CharSequence str, CharSequence prefix) {
        return startWith(str, prefix, false);
    }
}

Related

  1. startWith(String str, String start)
  2. startWith(String string, String prefix)
  3. startWith(String string1, String string2)
  4. startWithAorAn(String str)
  5. startWithBOM(byte[] array)
  6. startWithIgnoreCase(String str, String prefix)
  7. startWithLowerCase(String in)
  8. startWithLowerCase(String methodName)
  9. startWithProtocol(String input)