Checking whether the string is a purely digital

Checking whether the string is a number

Such as the title of the article, as follows:

	/**
	 * 校验字符串是否是纯数字
	 * 
	 * @param str 数字字符串
	 * @return boolean
	 */
	private static boolean isInteger(String str) {
        String s = "^[-+]?[\\d]*$";
        Pattern pattern = Pattern.compile(s);
        return pattern.matcher(str).matches();
    }
Published 42 original articles · won praise 10 · views 7062

Guess you like

Origin blog.csdn.net/MCJPAO/article/details/96107290