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 isValidEmail(String target) {
    return android.util.Patterns.EMAIL_ADDRESS.matcher(target.trim()).matches();
}

From source file:Main.java

/**
 * Tell whether the string contains a number.
 *///from   w  w  w .j a va2  s. com
public static boolean isNumber(String string) {
    String s = string.trim();
    if (s.length() < 1)
        return false;
    double value = 0;
    try {
        value = Double.parseDouble(s);
    } catch (NumberFormatException e) {
        return false;
    }
    return true;
}

From source file:Main.java

public static boolean isNullOrBlank(String content) {
    if (content == null || TextUtils.isEmpty(content.trim())) {
        return true;
    }/*w ww .j  a v  a 2  s  .co  m*/
    return false;
}

From source file:Main.java

public final static boolean isEmptyStr(String aStr) {
    if (null == aStr || 0 == aStr.length() || 0 == aStr.trim().length()) {
        return true;
    }//from  www.j  a v a  2s .  c o m
    return false;
}

From source file:Main.java

static boolean isNullOrBlank(String source) {
    return (source == null) || "".equals(source.trim());
}

From source file:Main.java

public static String parseEmpty(String str) {
    if (str == null || "null".equals(str.trim())) {
        str = "";
    }//ww w  .jav a2  s.  c om
    return str.trim();
}

From source file:Main.java

public static boolean isContainChinese(String str) {
    if (str == null || str.trim().length() <= 0) {
        return false;
    }/*from   www  .  ja v  a2  s . co m*/

    int len = str.length();
    for (int i = 0; i < len; i++) {
        char word = str.charAt(i);
        if ((word >= 0x4e00) && (word <= 0x9fbb)) {
            return true;
        }
    }
    return false;
}

From source file:Main.java

public static String MakeX10String(String nodeString) {
    String x10String = new String(nodeString);
    x10String.trim();
    System.err.println(x10String.startsWith("\'"));
    //nodeString.c
    String temp = "\'";
    if (x10String.startsWith("\'") && x10String.endsWith("\'")) {

        x10String = x10String.substring(1, x10String.length() - 1);

    }/* w  ww  .j  a  va  2s.c  om*/
    x10String = x10String.replace("\"", "\\\"");
    x10String = x10String.replace("\'\'", "\\\'");
    x10String = "\"" + x10String + "\"";
    return x10String;
}

From source file:Main.java

public static String md5(String string) {
    if (string == null || string.trim().length() < 1) {
        return null;
    }// w  ww.  j av a2 s.co  m
    try {
        return getMD5(string.getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}

From source file:Main.java

public static boolean validatePhone(String phone) {

    try {/*  w  w w.  j  a  v a  2s  . co  m*/
        if (phone.trim().length() == 0) {
            return false;
        }
        double n = Double.parseDouble(phone);
        if (!(phone.trim().toString().startsWith("7") || phone.trim().toString().startsWith("8")
                || phone.trim().toString().startsWith("9")))
            return false;
        if (phone.trim().length() == 10)
            return true;

    } catch (Exception e) {
        return false;
    }
    return false;
}