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 boolean isEmptyString(String str) {
    return str == null || str.length() == 0 || str.equals("null");
}

From source file:Main.java

public static String shortString(String str, int length) {
    if (str.length() < length + 2)
        return str;
    else//from   w w w . ja v a 2s  .  co  m
        return str.substring(0, length) + "..";
}

From source file:Main.java

public static boolean isEmpty(String str) {
    return str == null || str.length() == 0 ? true : false;
}

From source file:Main.java

public static byte[] HexToBuf(String auth) {
    int Leth = auth.length() / 2;
    byte[] HexByte = new byte[Leth];
    for (int a = 0; a < Leth; a++) {
        HexByte[a] = (byte) Integer.parseInt(auth.substring(a * 2, a * 2 + 2).toLowerCase(), 16);
    }//ww  w  .j a  v a  2s .c  om
    return HexByte;
}

From source file:Main.java

public static boolean isEmptyString(String str) {
    return str == null || str.length() == 0;
}

From source file:Main.java

private static boolean validatePin(String pin) {
    if (pin.length() == 4 && isDigit(pin.charAt(0)) && isDigit(pin.charAt(1)) && isDigit(pin.charAt(2))
            && isDigit(pin.charAt(3))) {
        return true;
    } else {//w  w  w.  j a  va 2  s. c  om
        return false;
    }
}

From source file:Main.java

public static boolean isNotEmpty(String str) {
    return str != null && str.length() > 0;
}

From source file:Main.java

static String addHtmlTags(String text) {
    final int n = text.length();
    if (n > 12 && text.substring(0, 6).equals("<html>") && (text.substring(n - 7, n).equals("</html>")))
        return text;
    else//from  w  w  w .  j  ava2  s.  c o m
        return "<html>" + text + "</html>";
}

From source file:Main.java

public static boolean isStringEmpty(String str) {
    return null == str || str.length() < 1;
}

From source file:Main.java

public static String getDateString(String year, String month) {
    return year + "-" + (month.length() == 1 ? "0" + month : month);
}