Here you can find the source of isNumeric(String str)
public static boolean isNumeric(String str)
//package com.java2s; //License from project: Open Source License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isNumeric(String str) { if (isNullOrEmpty(str)) { return false; }/*from ww w .jav a 2 s . c om*/ String NUMERIC_PATTERN = "^(-?\\d+)(\\.\\d+)?$"; Pattern pattern = Pattern.compile(NUMERIC_PATTERN); Matcher matcher = pattern.matcher(str); return matcher.matches(); } public static boolean isNullOrEmpty(String s) { return s == null || s.length() == 0; } public static boolean isNullOrEmpty(String... ss) { for (String s : ss) { if (s == null || s.length() == 0) { return true; } } return false; } }