I normally use the following idiom to check if a String can be converted to an integer.
public boolean isInteger( String input ) { try { Integer.
You can also use the Scanner class, and use hasNextInt() - and this allows you to test for other types, too, like floats, etc.