Here you can find the source of isNumber(String str, String sign)
public static boolean isNumber(String str, String sign)
//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, String sign) { String regex = ""; if ("+".equals(sign)) { regex = "^[+]?[0-9]*$"; } else if ("-".equals(sign)) { regex = "^[-][0-9]*$"; } else {/* w w w. j a v a 2 s .c om*/ regex = "^[+-]?[0-9]*$"; } return match(regex, str); } private static boolean match(String regex, String str) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(str); return matcher.matches(); } }