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 String trim(String word) {
    if (null != word)
        word = word.trim();
    return word;
}

From source file:Main.java

public static boolean containsChinese(String s) {
    if (null == s || "".equals(s.trim()))
        return false;
    for (int i = 0; i < s.length(); i++) {
        if (isChinese(s.charAt(i)))
            return true;
    }//  w  w  w.j a  va  2s. c o  m
    return false;
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static boolean isNullOrBlank(String input) {
    return input == null || (input != null && input.trim().equals(""));
}

From source file:Main.java

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

From source file:Main.java

private static String formatLocation(String address) {

    if (address != null && address.trim().length() > 0) {

        if (address.startsWith(","))
            return formatLocation(address.substring(1));
    }//w w  w.  j a v a  2  s.c o  m

    return address;

}

From source file:Main.java

public static boolean isEmptyArrayString(String arrayString) {
    return !(arrayString != null && !arrayString.trim().isEmpty() && !arrayString.equals("[]")
            && !arrayString.equals("[ ]"));
}

From source file:Main.java

/**
 * get the relation info's size/*from   w w w  . j ava2 s.  c  om*/
 * 
 * @param info
 * @return
 */
private static int getRelationInfoSize(String info) {
    if (info == null || info.trim().length() <= 0)
        return 0;
    String[] splitStr = info.split("\\Q#-#\\E"); //$NON-NLS-1$
    return splitStr.length;
}

From source file:Main.java

private static String makeUrlHerf(String content) {
    if (content.trim().length() == 0) {
        return content;
    }//from ww w. j av a  2s . c o  m
    StringBuffer urlStringBuffer = new StringBuffer();

    Matcher matcherUrl = patternURL.matcher(content);
    while (matcherUrl.find()) {

        String url = matcherUrl.group();
        //            System.out.println("URL:" + url);
        String urlToHref = "<a href=\"" + url + "\">" + url + "</a>";
        matcherUrl.appendReplacement(urlStringBuffer, urlToHref);

    }
    matcherUrl.appendTail(urlStringBuffer);
    return urlStringBuffer.toString();
}