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

/**
 * /*from w  ww .ja  va 2 s . c o  m*/
 * @param str
 * @return
 */
public static boolean isStringBlank(String str) {
    return (str == null) || ("".equals(str.trim()));
}

From source file:Main.java

public static int[] tointArray(String str, String seperator) {
    str = str.trim();
    if (str == null || str.isEmpty()) {
        return null;
    }/*from  www.  j a va2s.  com*/
    String[] arr = str.split(seperator);
    int[] result = new int[arr.length];
    for (int i = 0; i < arr.length; i++) {
        result[i] = Integer.parseInt(arr[i]);
    }
    return result;
}

From source file:Main.java

public static boolean isHasValue(String... editTexts) {
    for (String ed : editTexts) {
        String str = ed.trim();
        if (!TextUtils.isEmpty(str)) {
            return true;
        }//w  w w  .j  a va2 s . c o  m
    }
    return false;
}

From source file:Main.java

public static String[] extractTags(String source) {
    final List<String> result = new LinkedList<String>();
    for (String tag : source.split(",")) {
        if (tag.trim().length() > 0)
            result.add(tag.trim());//  w  ww . jav  a  2  s .  c  o m
    }
    return result.toArray(new String[result.size()]);
}

From source file:Main.java

public static String decodeMedals(String medals) {
    if ((medals != null) && (!medals.trim().equalsIgnoreCase(""))) {

        medals = medals.trim().replaceAll(",", " ");

    }//from  w ww. j a v  a 2 s .com

    return medals;
}

From source file:Main.java

public static String getFileName(String path) {
    if (path != null && !"".equals(path.trim())) {
        return path.substring(path.lastIndexOf("/"));
    }//from  w  w  w  . j  av a2 s.  c  o  m

    return "";
}

From source file:Main.java

public static boolean isNumeric(String str) {
    if (str == null || str.trim().equals("")) {
        return false;
    }// w w  w  .java 2  s .com
    Pattern pattern = Pattern.compile("[0-9]*");
    Matcher isNum = pattern.matcher(str);
    if (isNum.matches()) {
        return true;
    } else {
        return false;
    }
}

From source file:Main.java

public static boolean isEmptys(String... editTexts) {
    for (String ed : editTexts) {
        String str = ed.trim();
        if (TextUtils.isEmpty(str)) {
            return true;
        }/*from www .  j  a v  a2  s  .  c  o  m*/
    }
    return false;
}

From source file:Main.java

private static String getTrimmedString(String src) {
    String result = src.trim();
    if (result.length() == 0) {
        return result;
    }/*  w  w  w .ja va2 s .c o  m*/
    while (src.startsWith("\n")) {
        src = src.substring(1);
    }
    while (src.endsWith("\n")) {
        src = src.substring(0, src.length() - 1);
    }
    return src;
}

From source file:Main.java

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