判断字符串是否为数字的工具类

This commit is contained in:
mensc 2024-06-22 13:16:50 +08:00
parent bd75d75dfa
commit b7ff8f882d

View File

@ -0,0 +1,15 @@
package com.mtz.qqbot.Tool;
public class isNumber {
public static boolean isNum(String str) {
if (str == null || str.isEmpty()) {
return false;
}
try {
Integer.parseInt(str);
return true;
} catch (NumberFormatException e) {
return false;
}
}
}