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 int executeSqlStatements(SQLiteDatabase db, String[] statements) {
    int count = 0;
    for (String line : statements) {
        line = line.trim();
        if (line.length() > 0) {
            db.execSQL(line);/* w w w . j av  a  2 s  .  co m*/
            count++;
        }
    }
    return count;
}

From source file:Main.java

/**
 * Check CJK codepoints in <code>str</code>.
 * /* w ww .j  av  a 2s.  c o  m*/
 * @param str
 * @return <code>true</code> if <code>str</code> has at least one CJK codepoint, otherwise
 *         <code>false</code>.
 */
public static boolean isCJK(String str) {
    if (str == null || str.trim().equals(""))
        return false;
    for (int i = 0; i < str.length(); i++) {
        int codePoint = str.codePointAt(i);
        if (codePoint >= 19968 && codePoint <= 40911)
            return true;
    }
    return false;
}

From source file:Main.java

public static String fixHtmlText(String text) {
    if (text != null) {
        text = text.trim().replaceAll("\\\\+", "");
        text = text.replace("&amp;", "&");
        text = text.replace("&lt;", "<");
        text = text.replace("&gt;", ">");
        text = text.replace("&quot;", "\"");
    }//w  ww  . j a v  a  2  s .co m
    text = Html.fromHtml(text).toString();
    return text;
}

From source file:Main.java

public static String getRegistrationCodeFrom(String message) {
    String regCode = "";
    String[] parts = message.trim().split(" ");
    if (parts.length > 0) {
        regCode = parts[parts.length - 1];
    }//from w w  w.j  a v  a2 s.  c om
    return regCode;
}

From source file:Main.java

public static boolean isNotNull(String str) {
    return (str != null && !"".equalsIgnoreCase(str.trim()));
}

From source file:cloudify.widget.common.StringUtils.java

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

From source file:com.googlesource.gerrit.plugins.supermanifest.StringUtil.java

public static String addTab(String str) {
    StringBuffer buf = new StringBuffer("");
    for (String s : str.split("\n")) {
        if (!s.trim().isEmpty()) {
            buf.append("\t" + s + " \n");
        }//from  w  w  w .j  a v  a 2 s  .c  o m
    }
    return buf.toString();
}

From source file:Main.java

/**
 * Checks if is empty./*from w w  w .  j  a  v a  2s  . c om*/
 *
 * @param str the str
 * @return true, if is empty
 */
public static boolean isEmpty(String str) {
    return str == null || str.equalsIgnoreCase("null") || str.trim().length() == 0;
}

From source file:Main.java

public static boolean isLong(String str) {
    if ("0".equals(str.trim())) {
        return true;
    }//w w w  .java  2s . c o  m
    Pattern pattern = Pattern.compile("^[^0]\\d*");
    Matcher isNum = pattern.matcher(str);
    if (!isNum.matches()) {
        return false;
    }
    return true;
}

From source file:Main.java

public static boolean isEmptyString(String val) {
    boolean ret = false;

    if (val == null || val.trim().equals("")) {
        ret = true;//from   w  w w.  ja  va2 s .  co m
    }

    return ret;
}