Java Utililty Methods String Start With

List of utility methods to do String Start With

Description

The list of methods to do String Start With are organized into topic(s).

Method

booleanstartWith(String source, String target)
start With
if (source.length() < target.length()) {
    return false;
String sub = source.substring(0, target.length());
return target.equalsIgnoreCase(sub);
booleanstartWith(String str, String prefix)
start With
return str.startsWith(prefix);
booleanstartWith(String str, String start)
NullPoint safe.
if (str == null)
    return false;
return str.startsWith(start);
StringstartWith(String string, String prefix)
start With
if (empty(string)) {
    return prefix;
} else if (string.startsWith(prefix)) {
    return string;
} else {
    return prefix + string;
BooleanstartWith(String string1, String string2)
Indicates if the string 1 starts with string2.
return (string1 != null) ? string1.startsWith(string2) : false;
StringstartWithAorAn(String str)
start With Aor An
if (str.length() == 0)
    return str;
if ((!str.toUpperCase().startsWith("A ")) && (!str.toUpperCase().startsWith("AN "))
        && (!str.toUpperCase().startsWith("THE ")) && (!str.toUpperCase().startsWith("SOME "))) {
    if ("aeiouAEIOU".indexOf(str.charAt(0)) >= 0)
        return "an " + str;
    return "a " + str;
return str;
booleanstartWithBOM(byte[] array)
Test if the byte array starts with BOM.
if (array.length < 3) {
    return false;
if ((array[0] != (byte) 0xEF) || (array[1] != (byte) 0xBB) || (array[2] != (byte) 0xBF)) {
    return false;
return true;
booleanstartWithIgnoreCase(CharSequence str, CharSequence prefix)
start With Ignore Case
return startWith(str, prefix, true);
booleanstartWithIgnoreCase(String str, String prefix)
start With Ignore Case
if (str.length() < prefix.length())
    return false;
return prefix.equalsIgnoreCase(str.substring(0, prefix.length()));
StringstartWithLowerCase(String in)
start With Lower Case
return in.substring(0, 1).toLowerCase() + in.substring(1);