Java String Starts Wtih startsWith(String str, String prefix, boolean ignoreCase)

Here you can find the source of startsWith(String str, String prefix, boolean ignoreCase)

Description

starts With

License

Mozilla Public License

Declaration

private static boolean startsWith(String str, String prefix, boolean ignoreCase) 

Method Source Code

//package com.java2s;
//License from project: Mozilla Public License 

public class Main {
    public static boolean startsWith(String str, String prefix) {
        return startsWith(str, prefix, false);
    }//from  w  ww.jav  a  2s .  co  m

    private static boolean startsWith(String str, String prefix, boolean ignoreCase) {
        if (str == null || prefix == null) {
            return (str == null && prefix == null);
        }

        if (prefix.length() > str.length()) {
            return false;
        }

        return str.regionMatches(ignoreCase, 0, prefix, 0, prefix.length());
    }

    public static int length(String str) {
        return str == null ? 0 : str.length();
    }
}

Related

  1. startsWith(String str, String prefix)
  2. startsWith(String str, String prefix)
  3. StartsWith(String str, String prefix)
  4. startsWith(String str, String prefix)
  5. startsWith(String str, String prefix, boolean ignoreCase)
  6. startsWith(String str, String prefix, int index)
  7. startsWith(String str, String start, boolean caseSensitive)
  8. startsWith(String str1Raw, String str2Raw)
  9. startsWith(String string, char... ca)