您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Java库,用于检查字符串是否包含数字(无*例外)

Java库,用于检查字符串是否包含数字(无*例外)

我将避免重新发明此方法,而应使用Apache Commons。如果您使用Spring,Struts或许多其他常用的Java库,则它们通常包含Apache Commons。您将需要commons- lang.jar文件。这是您想要的NumberUtils中方法

isNumber[1]

public static boolean isNumber(java.lang.String str)
Checks whether the String a valid Java number.

Valid numbers include hexadecimal marked with the 0x qualifier, scientific notation and numbers marked with a type qualifier (e.g. 123L).

Null and empty String will return false.

Parameters:
str - the String to check
Returns:
true if the string is a correctly formatted number
java 2022/1/1 18:14:57 有475人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶