List of usage examples for java.lang String trim
public String trim()
From source file:Main.java
/** * Parses the given string and returns a double value. Returns null if the * given string is null or cannot be parsed as a double. * * @param value the string value./* ww w.j a v a 2 s. com*/ * @return a double value. */ public static Double parseDouble(String value) { if (value == null || value.trim().isEmpty()) { return null; } try { return Double.parseDouble(value); } catch (NumberFormatException ex) { return null; } }
From source file:Main.java
/** * Displays a {@link JOptionPane} as an Input Dialog asking for a required text. * * @param title The title of the dialog. * @return The text written by the user. *///from w w w.ja va 2 s . c om public static String askForRequiredTextUsingInputDialog(String title, String message) { String text = null; while (text == null || text.trim().equals("")) { text = JOptionPane.showInputDialog(null, message, title, JOptionPane.QUESTION_MESSAGE); } return text; }
From source file:Main.java
public static boolean hasMeaningful(String value) { return value != null && !"".equalsIgnoreCase(value.trim()) && !"null".equalsIgnoreCase(value.trim()); }
From source file:Main.java
public static ArrayList<Integer> includeWeek(String week, String weekLine) { weekLine = weekLine.trim(); ArrayList<Integer> result = new ArrayList<>(); String[] ss = weekLine.split("@"); for (int i = 0; i < ss.length; i++) { String[] s1 = ss[i].split("-"); if (s1.length == 1 && s1[0].trim().substring(0, s1[0].trim().length() - 1).trim().equals(week)) { result.add(i);// w w w . j a v a2 s .c o m } else if (s1.length == 2 && Integer.valueOf(s1[0].trim()) <= Integer.valueOf(week.trim()) && Integer .valueOf(s1[1].substring(0, s1[1].length() - 1).trim()) >= Integer.valueOf(week.trim())) { result.add(i); } } return result; }
From source file:Main.java
public static boolean isNullEmptyOrWhitespace(String value) { return value == null || value.isEmpty() || value.trim().isEmpty(); }
From source file:Main.java
public static boolean isEmpty(String str) { if (str != null && !"".equals(str.trim())) { return false; }/*from w w w . j av a 2 s.c o m*/ return true; }
From source file:Main.java
/** * @return true if the string is blank filled (space char filled) */// w w w. j av a 2s . c o m public static boolean isBlank(String s) { return (s.trim().length() == 0); }
From source file:Main.java
/** * @param activity/*w w w.j a v a2 s.c o m*/ * @param phone */ public static void phone(Activity activity, String phone) { phone = "tel:" + phone.trim(); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(phone)); activity.startActivity(intent); }
From source file:Main.java
/** * Parses an integer silently. Returns the Integer value of the given string. * Returns null if the input string is null, empty or if it cannot be parsed. * * @param string the string./*from w ww . j a v a2s. c om*/ * @return an Integer. */ public static Integer parseInt(String string) { if (string == null || string.trim().isEmpty()) { return null; } try { return Integer.parseInt(string); } catch (NumberFormatException ex) { return null; } }
From source file:Main.java
public static JSONArray newJSONArray(String val) { try {//from ww w. j a va 2 s . c om return new JSONArray(val.trim()); } catch (Exception e) { return null; } }