List of usage examples for java.lang Character isDigit
public static boolean isDigit(int codePoint)
From source file:Main.java
public static boolean isNumber(String str) { boolean check = true; for (int i = 0; i < str.length(); i++) { if (!Character.isDigit(str.charAt(i))) { check = false;/*from w w w . ja v a 2 s .c o m*/ break; } } return check; }
From source file:Main.java
public static boolean isAllDigit(String str) { if (!str.equals("") && str.length() > 0) { int len = 0; for (int idx = 0; idx < str.length(); idx++) { if (Character.isDigit(str.charAt(idx))) { len++;// w w w.j a v a 2 s . c o m } } if (len == str.length()) { return true; } } return false; }
From source file:Main.java
private static String getDigitsOnly(String s) { StringBuffer digitsOnly = new StringBuffer(); char c;//from w w w . j a v a 2 s.c om for (int i = 0; i < s.length(); i++) { c = s.charAt(i); if (Character.isDigit(c)) { digitsOnly.append(c); } } return digitsOnly.toString(); }
From source file:Main.java
public static boolean isNum(String content) { if (content.length() != 6) { return false; }//from ww w . java 2 s .c o m for (int i = 0; i < content.length(); i++) { char c = content.charAt(i); if (!Character.isDigit(c)) { return false; } } return true; }
From source file:Main.java
public static boolean isNumber(String s) { char ch;/*from w w w .ja va2 s. c o m*/ int id, len; boolean valid = true; len = s.length(); for (int i = 0; i < len; i++) { ch = s.charAt(i); if (!(Character.isDigit(ch) || ch == '-' || ch == '+' || ch == '.')) return false; } return true; }
From source file:Main.java
public static boolean isWholePositiveNumber(String value) { if (value == null) { return false; }/*from www . j a v a2s . com*/ for (char c : value.toCharArray()) { if (!Character.isDigit(c)) { return false; } } return true; }
From source file:Main.java
public static String computePhraseShape(String x) { StringBuilder buf = new StringBuilder(); char lastc = 0; for (int i = 0; i < x.length(); i++) { char c = x.charAt(i); if (Character.isDigit(c)) c = '0'; else if (Character.isLetter(c)) c = Character.isLowerCase(c) ? 'a' : 'A'; else if (Character.isWhitespace(c) || Character.isSpaceChar(c)) c = ' '; if (c != lastc) buf.append(c);//from ww w . j a v a2 s . co m lastc = c; } return buf.toString(); }
From source file:Main.java
public static boolean isNumeric(Object obj) { if (obj == null) { return false; }/*w ww .j a v a 2 s . com*/ String str = obj.toString(); int sz = str.length(); for (int i = 0; i < sz; i++) { if (!Character.isDigit(str.charAt(i))) { return false; } } return true; }
From source file:Main.java
public static boolean isPasswordValid(String password) { if (password.length() != 6) return false; for (int i = 0; i < password.length(); i++) { if (!Character.isDigit(password.charAt(i))) return false; }/*from www .j av a2 s .com*/ return true; }
From source file:Main.java
public static String stripNonNumeric(String str) { if (str == null) return null; String s = ""; int n = str.length(); char c;//from w ww . ja v a 2s . com for (int i = 0; i < n; i++) { c = str.charAt(i); if (Character.isDigit(c)) s += c; } return s; }