Use a regular expression - the matches() method of the String class does just that. For example, to check for integer values, use "[0-9]+" or "[\\d]+"

Lesson: Regular Expressions (The Java™...