判断字符串是否为数字的工具类
This commit is contained in:
parent
bd75d75dfa
commit
b7ff8f882d
15
src/main/java/com/mtz/qqbot/Tool/isNumber.java
Normal file
15
src/main/java/com/mtz/qqbot/Tool/isNumber.java
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user