xxxxxxxxxx
//Add this to your code and call
static private boolean isMyNumber(String s){
try{
Integer.parseInt(s);
return true;
}catch (Exception e){
return false;
}
}
xxxxxxxxxx
String numbers = "6969696969";
boolean check_n = numbers.matches("[0-9]+"); // true
String notNumber = "0123meowGOGO88l";
boolean check_s = notNumber.matches("[0-9]+"); // false
xxxxxxxxxx
String value = 12345
StringUtils.isNumeric(value) //returns true
xxxxxxxxxx
To find whether a given string contains a number,
convert it to a character array and find whether
each character in the array is a digit using the isDigit()
method of the Character class