List of usage examples for java.lang String trim
public String trim()
From source file:Main.java
/** * Checks if is blank.//from w w w. j a va 2s . c om * * @param value * the value * * @return true, if is blank */ public static boolean isBlank(String value) { return ((value == null) || (value.trim().length() == 0)); }
From source file:Main.java
/** * <p>/*from w w w . j a v a 2 s . com*/ * Removes control characters, including whitespace, from both ends of this String, handling <code>null</code> by * returning <code>null</code>. * </p> * * @param str the String to check * @return the trimmed text (or <code>null</code>) * @see java.lang.String#trim() */ public static String trim(String str) { return (str == null ? null : str.trim()); }
From source file:Main.java
private static List<String> parseParticipants(String s) { if (s == null || s.length() == 0) { return Collections.emptyList(); }//from w w w .ja v a 2 s. c o m String[] parts = s.split(","); List<String> ret = new ArrayList<String>(); for (String part : parts) { ret.add(part.trim()); } return ret; }
From source file:Main.java
public static boolean heightCheck(String heightStr) { if (heightStr == null || (heightStr.trim().equals(""))) { return false; }//from w w w . j av a 2 s.c om Pattern pattern = Pattern.compile("^[0-9]*$"); if (pattern.matcher(heightStr).matches()) { int hei = Integer.valueOf(heightStr); if ((hei > 140) && (hei < 200)) { return true; } else { return false; } } else { return false; } }
From source file:Main.java
/** * <p>// w w w .j ava 2 s . com * Removes control characters, including whitespace, from both ends of this String, handling <code>null</code> by * returning an empty String. * </p> * * @param str the String to check * @return the trimmed text (never <code>null</code>) * @see java.lang.String#trim() */ public static String clean(String str) { return (str == null ? "" : str.trim()); }
From source file:Main.java
public static Date parseDate(String dateString) { Matcher m = DATE_PATTERN.matcher(dateString.trim()); if (!m.matches()) { throw new IllegalArgumentException("\"" + dateString + "\" must be in YYYY-MM-DD format."); }//from w w w .ja v a2s.c o m Calendar c = Calendar.getInstance(); c.set(Integer.parseInt(m.group(1)), Integer.parseInt(m.group(2)) - 1, Integer.parseInt(m.group(3))); return c.getTime(); }
From source file:Main.java
public static String generateCacheUID(String model, String query, String[] params) { String uid = model;/*from ww w .j a v a2 s . c om*/ uid += query.trim(); for (String param : params) uid += param.trim(); return uid; }
From source file:Main.java
/** * Convert float value wraped in string to float safely. *//* ww w .j a v a2 s .co m*/ public static float toFloatSafely(String text) { float result = -1.0f; text = text.trim(); try { result = Float.parseFloat(text); } catch (NumberFormatException e) { e.printStackTrace(); } return result; }
From source file:Main.java
public static String filePathReplaceAll(String value) { String returnValue = value; if (returnValue == null || returnValue.trim().equals("")) { return ""; }/* w w w . ja v a2 s .c o m*/ returnValue = returnValue.replaceAll("/", ""); returnValue = returnValue.replaceAll("\\", ""); returnValue = returnValue.replaceAll("\\.\\.", ""); // .. returnValue = returnValue.replaceAll("&", ""); return returnValue; }
From source file:Main.java
public static boolean isNotBlank(String val) { if (val == null) return false; if (val.trim().length() == 0) return false; return true;// w ww. ja v a2 s . c o m }