Java Utililty Methods String Starts Wtih

List of utility methods to do String Starts Wtih

Description

The list of methods to do String Starts Wtih are organized into topic(s).

Method

booleanstartsWithChar(CharSequence s, char prefix)
starts With Char
return s != null && s.length() != 0 && s.charAt(0) == prefix;
booleanstartsWithChar(final String s, final char c)
starts With Char
if (s == null || s.length() == 0) {
    return false;
return s.charAt(0) == c;
booleanstartsWithChar(String s, char c)
starts With Char
if (s.length() == 0) {
    return false;
return s.charAt(0) == c;
booleanstartsWithChar(String string, char prefix)
Tests if this string starts with the specified prefix.
return string.length() > 0 && string.charAt(0) == prefix;
booleanstartsWithChar(String string, int character)
Return true if the given string starts with the given character.
return string.length() > 0 && string.charAt(0) == character;
booleanstartsWithCharacter(String str, char stringStart)
Checks if the string str starts with the given character
return str.length() > 0 && str.charAt(0) == stringStart;
booleanstartsWithCharacter(String str, String matchChars)
Check for defined Characters at start of Word or Sequence of words
for (int i = 0; i < str.length(); i++) {
    final char ch = str.charAt(i);
    final int index = matchChars.indexOf(ch);
    if (index != -1) {
        return true;
    } else {
        return false;
return false;
booleanstartsWithCommonPackagePrefix(String inputText)
starts With Common Package Prefix
return startsWithPrefix(inputText, new String[] { "java.", "javax.", "com.", "net.", "org." });
booleanstartsWithConcatenation(String string, String... prefixes)
Equivalent to string.startsWith(prefixes[0] + prefixes[1] + ...) but avoids creating an object for concatenation.
int offset = 0;
for (String prefix : prefixes) {
    int prefixLen = prefix.length();
    if (!string.regionMatches(offset, prefix, 0, prefixLen)) {
        return false;
    offset += prefixLen;
return true;
booleanstartsWithConcatenationOf(String testee, String firstPrefix, String secondPrefix)
Equivalent to testee.startsWith(firstPrefix + secondPrefix) but avoids creating an object for concatenation.
int l1 = firstPrefix.length();
int l2 = secondPrefix.length();
if (testee.length() < l1 + l2)
    return false;
return testee.startsWith(firstPrefix) && testee.regionMatches(l1, secondPrefix, 0, l2);