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 isHttpUrl(String url) {
    if (url != null && url.trim().toLowerCase().startsWith("http")) {
        return true;
    }//w  w w . jav a  2 s  .  c o  m
    return false;
}

From source file:Main.java

public static String ifEmptyReturnNull(String str) {
    if (str == null || str.trim().isEmpty()) {
        return null;
    }/*from  w ww  . java 2 s. com*/
    return str.trim();
}

From source file:Main.java

public static boolean isNotBlack(String msg) {
    if (msg == null || msg.trim().length() == 0) {
        return false;
    }//from  w w w . j  a  va 2  s.com
    return true;
}

From source file:Main.java

public static boolean parseBoolean(String value) {
    if (value.trim().equalsIgnoreCase("true"))
        return true;
    else// w  w  w  .j  av a2 s .c  om
        return false;
}

From source file:Main.java

@Deprecated
public static byte[] parseHexString(String str) {
    str = str.trim();
    String[] temps = str.split(" ");
    byte[] ret = new byte[temps.length];
    int i = 0;/*from   ww w.  j  a v  a  2 s.c  o m*/
    for (String t : temps) {
        ret[i] = Integer.valueOf(t, 16).byteValue();
        i++;
    }
    return ret;
}

From source file:Main.java

public static boolean isNotEmpty(String str) {
    if (str == null || str.trim().equals(""))
        return false;
    return true;//from w  ww .  ja  v  a  2s.  com
}

From source file:Main.java

static String dropSpaces(String s) {
    return (s == null) ? null : s.trim().replaceAll("\\s+", "");
}

From source file:Main.java

public static boolean stringIsEmpty(String str) {
    if (str == null || str.trim().length() <= 0) {
        return true;
    }/*www.  j av  a 2s .com*/
    return false;
}

From source file:Main.java

public static String normalizeName(String name) {

    String resp = name.trim();
    while (resp.indexOf("  ") != -1) {
        resp = resp.replace("  ", " ");
    }/* w  ww. j  ava 2s  .c  o m*/
    return resp;
}

From source file:Main.java

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