Java Utililty Methods String Length Get

List of utility methods to do String Length Get

Description

The list of methods to do String Length Get are organized into topic(s).

Method

intlengthExpandedTabs(String string, int toIdx, int tabWidth)
Returns the length of a String prefix with tabs expanded.
int len = 0;
for (int idx = 0; idx < toIdx; idx++) {
    if (string.charAt(idx) == '\t') {
        len = (len / tabWidth + 1) * tabWidth;
    } else {
        len++;
return len;
StringlengthExpression(final String operand, final long length)
Build expression to check the 'length' restriction, depending on the data type of the member variable.
return String.format("%s.length() != %d", operand, length);
StringlengthField(String propertyName)
Creates the name of the Lucene document field which will store the length of a property.
return LENGTH_PREFIX + propertyName;
StringlengthFormat(String str, int maxLength)
length Format
return str.length() > maxLength ? str.substring(0, maxLength) + "..." : str;
intlengthIfAllAlpha(String str)
length If All Alpha
int len = (str == null) ? 0 : str.length();
for (int i = 0; i < len; ++i) {
    char c1 = str.charAt(i);
    if (!((c1 >= 'A' && c1 <= 'Z') || (c1 >= 'a' && c1 <= 'z'))) {
        return 0;
return len;
...
intlengthIntegers(String str)
Length string
int length = 0;
if (str != null && !str.equals("null") && !str.equalsIgnoreCase("")) { 
    String[] strArray = str.split(",");
    length = strArray.length;
return length;
intlengthMinusColors(String thisStr)
length Minus Colors
int size = 0;
for (int i = 0; i < thisStr.length(); i++) {
    if (thisStr.charAt(i) == '^') {
        i++;
        if ((i + 1) < thisStr.length()) {
            final int tagStart = i;
            final char c = thisStr.charAt(i);
            if ((c == '<') || (c == '&'))
...
intlengthMinusTrailingWhitespace(String line)
Returns the length of a string ignoring all trailing whitespace.
int len = line.length();
for (int i = len - 1; i >= 0; i--) {
    if (!Character.isWhitespace(line.charAt(i))) {
        break;
    len--;
return len;
...
intlengthOfCommonPrefix(String s1, String s2)
length Of Common Prefix
if (s1 == null || s2 == null)
    return 0;
int i = 0;
for (; i < Math.min(s1.length(), s2.length()); ++i) {
    if (s1.charAt(i) != s2.charAt(i)) {
        break;
return i;
intlengthOfStartingWhitespace(String s)
length Of Starting Whitespace
int n = s.length();
for (int i = 0; i < n; i++) {
    char c = s.charAt(i);
    if (c != ' ' && c != '\t') {
        return i;
return n;
...