There may be good reasons for re‑throwing an Exception, or wrapping it in another Exception.
You should find lots about that in the
Java Tutorials. You should not be wrapping unchecked Exceptions in checked Exceptions as in the earlier example. You should allow unchecked Exceptions to propagate, and later work out how to prevent them happening. Any subclasses of java.lang.Exception should be called Something
Exception.
Now people will tell you that NumberFormatException (NFE) is unavoidable, but that isn't actually true.
If you are reading a file you need to ensure that the format of the file matches the order of tokens used in the program. You can use a Scanner to check the tokens before reading them, and you can even wind back the Scanner, but I have never tried that, and don't know how it works. Not only can a Scanner convert a
String or similar input to numbers, but it can also warn you before you read it wrongly. Try this little class and run it from the command line/terminal as follows
java NumberIdentifier 12345 123.45 1234567890.1234567890 12345678901234567890123456789012345678901234567890 -12345 -123.45 -1234567890.1234567890 -12345678901234567890123456789012345678901234567890
Now just as
you can use a loop to prevent an InputMismatchException with Scanner, you can use those same methods to prevent NFEs.