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

booleanstartsWith(final CharSequence target, final CharSequence prefix)
starts With
if (target == null || prefix == null) {
    return false;
if (target == prefix) {
    return true;
final int prefixLength = prefix.length();
if (prefixLength > target.length()) {
...
booleanstartsWith(final E[] array, final E[] prefix)
starts With
if (prefix.length > array.length) {
    return false;
for (int i = 0; i < prefix.length; i++) {
    if (prefix[i] == null ? array[i] != null : !prefix[i].equals(array[i])) {
        return false;
return true;
booleanstartsWith(final Object[] left, final Object[] right, final boolean equals)
Checks whether the second array is a subsequence of the first array, and that they share common starting elements.
if (left == null || right == null) {
    return false;
int l = left.length;
int r = right.length;
if (r > l || !equals && r == l) {
    return false;
for (int i = 0; i < r; i++) {
    if (!equals(left[i], right[i])) {
        return false;
return true;
booleanstartsWith(final String fullMethodName, final String prefix)
starts With
final int length = prefix.length();
if (length >= fullMethodName.length()) {
    return false;
} else {
    final char startingCharacter = fullMethodName.charAt(length);
    return fullMethodName.startsWith(prefix) && Character.isUpperCase(startingCharacter);
booleanstartsWith(final String s, final String prefix, final boolean ignoreCase)

Check if a String starts with a specified prefix (optionally case insensitive).

if (s == null || prefix == null) {
    return s == null && prefix == null;
if (prefix.length() > s.length()) {
    return false;
return s.toString().regionMatches(ignoreCase, 0, prefix.toString(), 0, prefix.length());
booleanstartsWith(final String s, final String[] prefixes)
Test if a String starts with one of the prefix of a list in an array
if (s == null || prefixes == null) {
    return false;
for (String p : prefixes) {
    if (s.startsWith(p)) {
        return true;
return false;
booleanstartsWith(final String searchString, final String crit)
starts With
if (hasLength(searchString) && hasLength(crit)) {
    return searchString.startsWith(crit);
return false;
booleanstartsWith(final String source, final String prefix)
Tests if the source string starts with the prefix string.
return prefix.length() <= source.length() && source.regionMatches(true, 0, prefix, 0, prefix.length());
booleanstartsWith(final String src, final String sub)
Determines if the source starts with the substring
return (src == null) || (sub == null) ? false : src.startsWith(sub);
booleanstartsWith(final String str, final char prefix)
Check if a String starts with a specified prefix character.
return str != null && str.length() > 0 && str.charAt(0) == prefix;