Java's ParseException

I've been investigating Java's ParseException, when trying to write my own method that parses from a String to an int, and have two questions:

  1. When should I throw it? Java's Integer.parseInt(String string) throws a NumberFormatException when an invalid input is given (makes sense with it being a subclass of IllegalArgumentException), and does not throw ParseException at all.
  2. What is "errorOffset"? ParseException's constructor forces you to give it a value - what does it mean?


Throwing a ParseException for a parseXYZ() method (that actually parses something) is perfectly valid. Integer.parseInt throws a NumberFormatException since it is a subtype of RuntimeException and therefore does not force you to surround it with try-catch (This is not true for ParseException).

The offset field is used to identify the position for which the error occurred. With that information, you may be able to use whatever partial data you already parsed.

Need Your Help

Writing bash script for restarting JVMs

java linux ant

I have an application which is deployed on Linux environment and has two JVM's simultaneously running. One is producer and one is consumer.

jQuery BlockUi Message after another

javascript jquery jquery-plugins blockui

I'm using jQuery BlockUI plugin, and i have been able to sucessfully show a single message in the page, however... let's say that I want to show 3 messages , one after another.