Check If String Is Integer
Check if the value of a String variable is an Integer value.
Javadoc available at https://www.javatapas.com/docs/javatapas/string/CheckIfStringIsInteger.html
public static boolean checkIfStringIsInteger(String inStr) {
return checkIfStringIsInteger(inStr,10);
}
public static boolean checkIfStringIsInteger(String inStr, int radix) {
if(inStr.isEmpty()) return false;
for(int i = 0; i < inStr.length(); i++) {
if(i == 0 && inStr.charAt(i) == '-') {
if(inStr.length() == 1) return false;
else continue;
}
if(Character.digit(inStr.charAt(i),radix) < 0) return false;
}
return true;
}