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(String str, String prefix)
 StringUtilities.startsWith(null, null)      = true StringUtilities.startsWith(null, "abc")     = false StringUtilities.startsWith("abcdef", null)  = false StringUtilities.startsWith("abcdef", "abc") = true StringUtilities.startsWith("ABCDEF", "abc") = false 
return startsWith(str, prefix, false);
booleanStartsWith(String str, String prefix)
Starts With
if (str == null) {
    throw new NullPointerException("str");
if (prefix == null) {
    throw new NullPointerException("prefix");
return (prefix.length() >= str.length()) && str.substring(0, prefix.length()).equals(prefix);
booleanstartsWith(String str, String prefix, boolean ignoreCase)
starts With
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());
booleanstartsWith(String str, String prefix, boolean ignoreCase)

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

if (str == null || prefix == null) {
    return (str == null && prefix == null);
return prefix.length() <= str.length() && str.regionMatches(ignoreCase, 0, prefix, 0, prefix.length());
booleanstartsWith(String str, String prefix, int index)
starts With
if (str == null || prefix == null || index < 0 || index >= str.length())
    throw new IllegalArgumentException();
int endpos = prefix.length() + index;
if (endpos > str.length())
    return false;
return str.substring(index, endpos).equals(prefix);
booleanstartsWith(String str, String start, boolean caseSensitive)
starts With
if (str == null || start == null) {
    return (str == null && start == null);
if (start.length() > str.length()) {
    return false;
return str.regionMatches(caseSensitive, 0, start, 0, start.length());
booleanstartsWith(String str1Raw, String str2Raw)
starts With
String str1 = str1Raw.toLowerCase();
String str2 = str2Raw.toLowerCase();
for (int i = 0; i < str1.length() && i < str2.length(); i++) {
    if (str1.charAt(i) != str2.charAt(i)) {
        return false;
return true;
...
booleanstartsWith(String string, char... ca)
starts With
int l = ca.length;
for (int i = 0; i < l; i++) {
    if (string.charAt(i) != ca[i])
        return false;
return true;
booleanstartsWith(String string, String prefix)
Indicate if the given string starts with the given prefix.
return string.regionMatches(true, 0, prefix, 0, prefix.length());
booleanstartsWith(String string, StringBuffer prefix, int toffset)
starts With
return regionMatches(string, toffset, prefix, 0, prefix.length());