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

/**
 * Whether the given URL is one of the expected URLs used in the bootstrapping process
 * of the app.  Used for determining the app's "home page" URL.
 * @param url The URL to compare against the reserved list.
 * @return True if this URL is used in the bootstrapping process, false otherwise.
 *//*w  ww  . ja  v a 2 s.co m*/
private static boolean isReservedUrl(String url) {
    if (url == null || url.trim().equals(""))
        return false;
    for (String reservedUrlPattern : RESERVED_URL_PATTERNS) {
        if (url.toLowerCase(Locale.US).contains(reservedUrlPattern.toLowerCase(Locale.US)))
            return true;
    }
    return false;
}

From source file:Main.java

public static boolean isEmptyOrNull(String string) {
    if (string == null || string.trim().length() == 0 || string.equalsIgnoreCase("null")) {
        return true;
    } else {/*from   w w w . ja v  a2s .  com*/
        return false;
    }
}

From source file:Main.java

public static boolean checkEmailValid(String email) {
    if ((email == null) || (email.trim().length() == 0)) {
        return false;
    }/*  w ww . ja v a2 s  . c o  m*/
    String regEx = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$";
    Pattern p = Pattern.compile(regEx);
    Matcher m = p.matcher(email.trim().toLowerCase());

    return m.find();
}

From source file:Main.java

public static boolean isEmpty(String str) {
    if (str == null || TextUtils.isEmpty(str.trim()) || "null".equals(str.trim())) {
        return true;
    }/*from  www.  j  a va2 s .co m*/
    return false;
}

From source file:Main.java

private static String getUseableCondition(String condition) {
    if (null == condition || "".equals(condition.trim())) {
        return "";
    }/*from   w  w w .  j  ava 2  s.  c o  m*/
    return " AND " + condition;
}

From source file:Main.java

public static boolean isEmail(String email) {
    if (email == null || email.trim().length() == 0)
        return false;
    return emailer.matcher(email).matches();
}

From source file:Main.java

public static boolean checkNotNullString(String param) {
    boolean status = false;
    if (param.trim().length() > 0) {
        status = true;/*  w w  w . j  av  a  2 s. c  o m*/
    }
    return status;
}

From source file:Main.java

static boolean hasSurroundingRegExpSlashes(String str) {
    return str != null ? str.trim().matches("^/.*/$") : false;
}

From source file:Main.java

public static String getDateStringFromDate(Date date) {
    SimpleDateFormat formatter;//from www.ja  va 2 s . c o  m
    formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", java.util.Locale.CHINA);
    String dateString = formatter.format(date);
    return dateString.trim();
}

From source file:Main.java

public static String[] parseString(String raw, String split) {
    if (null == raw || 0 == raw.length()) {
        return null;
    }/*from   w w w  .j a va2 s.com*/
    String[] names = raw.split(",");
    String[] newNames = new String[names.length];
    int i = 0;
    for (String name : names) {
        newNames[i++] = name.trim();
    }
    return newNames;
}