String numbers = "6969696969"; boolean check_n = numbers.matches("[0-9]+"); // true String notNumber = "0123meowGOGO88l"; boolean check_s = notNumber.matches("[0-9]+"); // false