Here you can find the source of isNumber(String str)
public static boolean isNumber(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 isNumber(String str) { boolean bool = false; String regex = "[0-9]*"; bool = check(str, regex);/*from w w w . j a v a 2 s .c o m*/ return bool; } public static boolean check(String str, String regex) { boolean flag = false; try { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(str); flag = matcher.matches(); } catch (Exception e) { flag = false; } return flag; } }