Write code to check if a string is Numeric using BigDecimal
import java.math.BigDecimal; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static void main(String[] argv){ String str = "book2s.com"; System.out.println(isNumeric(str)); }/*from ww w . j ava 2 s .com*/ private static boolean isNumeric(String str) { if (StringHelper.isBlank(str)) { return false; } boolean flag = false; try { new BigDecimal(str); flag = true; } catch (NumberFormatException ex) { flag = false; } return flag; } public static boolean isBlank(String str) { int strLen; if (str == null || (strLen = str.length()) == 0) return true; for (int i = 0; i < strLen; i++) if (!Character.isWhitespace(str.charAt(i))) return false; return true; } }