Here you can find the source of isNumeric(String str)
public static boolean isNumeric(String str)
//package com.java2s; public class Main { public static boolean isNumeric(String str) { int index = str.indexOf("."); if (index == -1) { return isIntegral(str); }/*from w w w . j a va 2 s . c o m*/ if ((index == 0) || (index == str.length() - 1)) { return false; } String num1 = str.substring(0, index); String num2 = str.substring(index + 1); return (isIntegral(num1)) && (isAllCharDigit(num2)); } public static boolean isIntegral(String str) { if (str.startsWith("-")) { if (str.length() == 1) { return false; } str = str.substring(1); } if ((str.startsWith("0")) && (str.length() > 1)) { return false; } return isAllCharDigit(str); } public static boolean isAllCharDigit(String str) { int length = str.length(); if (length == 0) { return false; } for (int i = 0; i < length; i++) { if (!Character.isDigit(str.charAt(i))) { return false; } } return true; } }