Example usage for java.lang String trim

List of usage examples for java.lang String trim

Introduction

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

Prototype

public String trim() 

Source Link

Document

Returns a string whose value is this string, with all leading and trailing space removed, where space is defined as any character whose codepoint is less than or equal to 'U+0020' (the space character).

Usage

From source file:Main.java

public static boolean isNullOrEmpty(String str) {
    if (null == str || "".equals(str.trim())) {
        return true;
    }// ww  w .ja va2  s . com
    return false;
}

From source file:Main.java

/**
 * A checker for whether or not the input value is entirely whitespace. This is slightly more
 * aggressive than the android TextUtils#isEmpty method, which only returns true for
 * {@code null} or {@code ""}./*www . ja  v  a2  s  . co m*/
 *
 * @param value a possibly blank input string value
 * @return {@code true} if and only if the value is all whitespace, {@code null}, or empty
 */
public static boolean isBlank(String value) {
    return value == null || value.trim().length() == 0;
}

From source file:Main.java

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

From source file:Main.java

public static boolean isEmpty(@Nullable String str) {
    return str == null || str.trim().isEmpty();
}

From source file:Main.java

public static boolean isEmpty(String str) {
    return ((str == null) || ("".equals(str.trim())));
}

From source file:Main.java

public static String trim(String s) {
    s = s.split("\n")[0];
    s = s.trim();
    return s;
}

From source file:Main.java

public static String firstLetterToUpperCase(String name) {
    if (name.trim().length() == 0) {
        return name;
    }//from ww w .  ja v a 2s.  co  m
    char c[] = name.toCharArray();
    c[0] = Character.toUpperCase(c[0]);
    name = new String(c);
    return name;
}

From source file:Main.java

public static boolean isNull(String text) {
    if (text == null || "".equals(text.trim()) || "null".equals(text))
        return true;
    return false;
}

From source file:Main.java

public static String stripCDATA(String s) {
    s = s.trim();
    if (s.startsWith("<![CDATA[")) {
        s = s.substring(9);//  w  ww.  ja va 2 s  . c  o m
        int i = s.indexOf("]]>");
        if (i == -1) {
            throw new IllegalStateException("argument starts with <![CDATA[ but cannot find pairing ]]>");
        }
        s = s.substring(0, i);
    }
    return s;
}

From source file:Main.java

public static boolean validateParams(String... params) {
    for (String s : params) {
        if (s == null && s.trim().equals(""))
            return false;
    }//  w  ww.  j  a  v  a 2  s.  c  o m
    return true;
}