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 checkData(String string) {
    return !string.isEmpty() && string.trim().length() != 0;
}

From source file:Main.java

public static boolean isEmpty(String string) {
    if (string == null || string.trim().equals("")) {
        return true;
    }/*w w  w.j ava  2  s .  c  o  m*/
    return false;
}

From source file:Main.java

/**
 * Normalizes a URN by trimming whitespace, converting to lowercase, removing the prefix, 
 * and all labels such as <i>partType=</i>.
 * //  www  .ja  v  a  2 s . c  om
 * @param urn the URN to normalize
 * @return the normalized URN
 */
static public String normalizeURN(String urn) {
    urn = urn.trim();
    urn = urn.toLowerCase();
    urn = urn.replaceAll(TOPO_ID_PREFIX + TOPO_ID_SEPARATOR, "");
    for (String part : TOPO_ID_PARTS) {
        urn = urn.replaceAll(part + TOPO_ID_LABEL_SEPARATOR, "");
    }

    return urn;
}

From source file:Main.java

/**
 * @param str//from w  ww .j a  v  a2s . com
 * @return the trimmed string
 * 
 * @see java.lang.String#trim()
 */
public static synchronized String trim(String str) {
    return str.trim();
}

From source file:Main.java

public static boolean hasContent(String str) {
    return str != null && str.trim().length() > 0;
}

From source file:Main.java

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

From source file:Main.java

public static boolean isNullOrEmpty(String param) {
    if (isNull(param) || param.trim().length() == 0) {
        return true;
    }//  w ww .j  a  v a  2s. co m
    return false;
}

From source file:Main.java

public static String cleanText(String text, String removeCharacter) {
    return text.trim().replace(removeCharacter, "");
}

From source file:Main.java

public static String transformNULLToLine(String str) {
    if (str == null || "".equals(str.trim()) || "null".equals(str.trim()))
        return "-";
    return str;//from   ww w  .j a  va2  s. co m
}

From source file:Main.java

/**
 * /*from ww w.jav  a 2 s.co  m*/
 * @param HHmm
 * @return
 */
public static String to12Hours(String HHmm) {
    String[] t = HHmm.trim().split(":");
    int start = Integer.parseInt(t[0]);
    String a = "am";
    if (start > 12) {
        start -= 12;
        a = "pm";
    }
    return String.valueOf(start) + ":" + t[1] + a;
}