Here you can find the source of isAllDigital(String str)
public static boolean isAllDigital(String str)
//package com.java2s; public class Main { public static boolean isAllDigital(String str) { boolean is = true; if (getCharNum(str, '.') >= 2) { return false; }/*from www .j a v a 2s. c o m*/ for (int i = 0; i < str.length(); ++i) { if ((str.charAt(i) - '0' < 0 || str.charAt(i) - '9' > 0) && str.charAt(i) - '.' != 0) { is = false; break; } } return is; } public static int getCharNum(String str, char ch) { int num = 0; for (int i = 0; i < str.length(); ++i) { if (str.charAt(i) - ch == 0) { num++; } } return num; } }