Example usage for java.lang String length

List of usage examples for java.lang String length

Introduction

In this page you can find the example usage for java.lang String length.

Prototype

public int length() 

Source Link

Document

Returns the length of this string.

Usage

From source file:Main.java

public static String getIntiCapString(String param) {
    if (param != null && param.length() > 0) {
        char[] charArray = param.toCharArray();
        charArray[0] = Character.toUpperCase(charArray[0]);
        return new String(charArray);
    } else {/*from  ww  w . j  av a 2s  . c om*/
        return "";
    }
}

From source file:Main.java

public static boolean isPalindrome(String inputString) {
    int len = inputString.length();
    if (len <= 1) {
        return true;
    }/*  w  w w  .jav a 2 s.  com*/
    String newStr = inputString.toUpperCase();
    boolean result = true;
    int counter = len / 2;
    for (int i = 0; i < counter; i++) {
        if (newStr.charAt(i) != newStr.charAt(len - 1 - i)) {
            result = false;
            break;
        }
    }
    return result;
}

From source file:Main.java

public static Float testNumber(String aArg) {
    while (true) {
        if (aArg.length() == 0) {
            return null;
        }/*from w  w  w. ja  va2 s. co  m*/
        if (aArg.matches("-?\\d+(\\.\\d+)?") == true) {
            break;
        } else {
            throw new IllegalArgumentException("not a number");
        }
    }
    return Float.parseFloat(aArg);
}

From source file:Main.java

static String removeJunk(String string) {
    int i, len = string.length();
    StringBuffer dest = new StringBuffer(len);
    char c;/*from   w  w  w .j  ava  2 s .c  o m*/

    for (i = (len - 1); i >= 0; i--) {
        c = string.charAt(i);
        if (Character.isLetterOrDigit(c)) {
            dest.append(c);
        }
    }
    return dest.toString();
}

From source file:Main.java

public static boolean isTooBig(String s) {
    return s.length() >= 50;
}

From source file:Main.java

public static boolean isPrimitiveType(String type) {
    return type.length() == 1;
}

From source file:Main.java

public static String getTruncatedString(String str) {
    if (str.length() > 8)
        return str.substring(0, 5) + "...";
    return str;//ww  w . j  ava  2  s  . c om
}

From source file:Main.java

public static boolean isEmailAccount(String text) {
    return text.length() > 4;
}

From source file:Main.java

public static boolean isNameValid(String name) {
    return name.length() > 0;
}

From source file:Main.java

public static String getShortName(String name) {
    return (name.length() > 25) ? name.substring(0, 25) + "..." : name;
}