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

private static boolean isEmptyLine(String line) {
    return line.trim().length() == 0;
}

From source file:Main.java

public final static boolean isNumeric(String numberStr) {
    if (numberStr != null && !"".equals(numberStr.trim())) {
        return numberStr.matches("^[0-9]*$");
    } else {/*from w  w  w. j ava2s  .c o m*/
        return false;
    }
}

From source file:Main.java

public static boolean isValid(String src) {
    return !(src == null || "".equals(src.trim()));
}

From source file:Main.java

public static String getCookieValue(Context context, String url, String key) {
    CookieSyncManager csm = CookieSyncManager.createInstance(context);
    CookieManager cookieManager = CookieManager.getInstance();
    csm.sync();// w w  w.  j  av a 2  s .c  o m
    String cookieStr = cookieManager.getCookie(url);
    System.out.println("========cookied:" + cookieStr);
    String[] strs = cookieStr.split(";");
    String value = null;
    for (String string : strs) {
        if (string.trim().startsWith(key)) {
            value = string.substring(string.indexOf("=") + 1);
            break;
        }
    }
    return value;
}

From source file:com.google.dart.ui.test.matchers.HasTextWidgetMatcher.java

/**
 * Normalizes given {@link String} by removing special characters.
 *//*from   w  w  w  .  jav a  2  s  . c o  m*/
private static String normalizeWidgetText(String s) {
    s = s.trim();
    s = StringUtils.remove(s, '&');
    s = StringUtils.substringBefore(s, "\t");
    return s;
}

From source file:Main.java

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

From source file:Main.java

public static Set<String> split(String string, String separator) {
    Set<String> set = new HashSet<String>();
    if (string == null)
        return set;
    String[] split = string.split(separator);
    for (String v : split)
        set.add(v.trim());

    return set;/*from w  ww.  j a  v a 2 s . com*/

}

From source file:Main.java

private static String readEncoding(String contentEncoding, String contentType, String fallback) {
    String encoding = fallback;/*from   w  w  w  .jav a2 s.  com*/
    String[] values = contentType.split(";");
    if (contentEncoding != null) {
        encoding = contentEncoding;
    } else {
        for (String value : values) {
            value = value.trim();
            if (value.toLowerCase().startsWith("charset=")) {
                encoding = value.substring("charset=".length());
            }
        }
    }
    return encoding;
}

From source file:Main.java

public static boolean isNull(final String strSource) {
    return strSource == null || "".equals(strSource.trim());
}

From source file:Main.java

public static boolean isJson(String json) {
    if (json != null && !json.equals("[]") && !json.trim().equals("")) {
        return true;
    }//from   ww  w .j  a  v  a 2s  .c om
    return false;
}