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 first_letter_uppercase(String source) {

    StringBuffer res = new StringBuffer();

    String[] strArr = source.split(" ");
    for (String str : strArr) {
        char[] stringArray = str.trim().toCharArray();
        stringArray[0] = Character.toUpperCase(stringArray[0]);
        str = new String(stringArray);

        res.append(str).append(" ");
    }//from  w  w  w  .jav a  2 s  .  c  om

    return String.valueOf(res);
}

From source file:Main.java

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

From source file:Main.java

private static String buildCondition(String propType) {
    if (propType == null || propType.trim().length() == 0) {
        return "";
    }//from  w ww .j av a  2s . co  m
    String s = " tuv.updated_by_project = '";
    StringBuffer sb = new StringBuffer(s);
    String[] projects = propType.split(",");
    for (int i = 0; i < projects.length; i++) {
        if (i == projects.length - 1) {
            sb.append(projects[i]).append("'");
        } else {
            sb.append(projects[i]).append("'").append(" or ").append(s);
        }

    }
    return sb.toString();
}

From source file:Main.java

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

From source file:Main.java

public static String stringNull(String s) {
    if (s != null) {
        s = s.trim();
        if (s.equals("") || s.equalsIgnoreCase("null"))
            s = "";
    }//from  ww w. ja  v  a2 s .  co  m
    return s;
}

From source file:Main.java

/**
 * <p>//from   w  ww .j a v  a2s . co  m
 * Checks if a String is non <code>null</code> and is not empty (<code>length > 0</code>).
 * </p>
 *
 * @param str the String to check
 * @return true if the String is non-null, and not length zero
 */
public static boolean isNotEmpty(String str) {
    return ((str != null) && (str.trim().length() > 0));
}

From source file:Main.java

/**
 * checks if a condition is true//  www.  j  ava 2 s.c om
 *
 * @param condition value of the condition attribute
 * @return result of the evaluation of the condition
 */
public static boolean checkCondition(String condition) {
    if ((condition == null) || condition.trim().equals("")) {
        return true;
    }

    String value = condition.trim();
    if (value.charAt(0) == '!') {
        return System.getProperty(value.substring(1)) == null;
    }

    return System.getProperty(value) != null;
}

From source file:Main.java

public static String getParakeetURL(Context context) {
    String my_receivers = PreferenceManager.getDefaultSharedPreferences(context)
            .getString("wifi_recievers_addresses", "").trim();
    if (my_receivers.equals(""))
        return null;

    String[] hosts = my_receivers.split(",");
    if (hosts.length == 0)
        return null;

    for (String host : hosts) {
        host = host.trim();
        if ((host.startsWith("http://") || host.startsWith("https://"))
                && (host.contains("/json.get") || host.contains("Parakeet"))) {
            return host;
        }/*  w ww .j  a  va 2s  .  c o m*/
    }
    return null;
}

From source file:Main.java

private static String removeNullStr(String value) {
    try {/*w  w  w  .j  a v a2s  . co  m*/
        if (value != null && value.trim().equalsIgnoreCase("null")) {
            return "";
        } else {
            return value;
        }
    } catch (Exception e) {
        return "";
    }
}

From source file:Main.java

public static boolean isEmail(String email) {

    if (null == email || "".equals(email.trim()))
        return false;

    // String strPattern =
    // "^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$";
    Pattern p = Pattern.compile("^.*@{1}.+\\.{1}.*$");
    Matcher m = p.matcher(email);

    return m.matches();
}