What is the proper way to handle a NumberFormatException when it is expected?

Is there a method that I can call that will tell me if Integer.parseInt() will throw a NumberFormatException before calling it? Then I would have no problem logging this, since it should never happen. Sadly, no. At least not in the core Java API. It’s easy to write one, however – just modify the code … Read more