To catch illegal number conversion, try using the try/catch mechanism.
public class Main { public static void main(String[] args) throws Exception { try { int i = Integer.parseInt("asdf"); } catch (NumberFormatException e) { ; } } }