Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Who throws NumberFormatException  RSS feed

 
William Barnes
Ranch Hand
Posts: 1049
2
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know how I can get a list of all opertions which can throw a NumberFormatException?
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if such a list is available. That particular information doesn't seem very useful to me. However, the Java API documentation DOES tell you what exceptions are thrown by each individual method. In my opinion, this is much more useful to know when you are programming in Java. Of course, I may just be stuck in my way of thinking. Is there a reason you need to know all methods that throw a particular excpetion?

Layne
 
William Barnes
Ranch Hand
Posts: 1049
2
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to fix a code review item which says you need to handle all NumberFormatExceptions. There is lots of code and the people who wrote it didn't always do a try and catch for every possible place for which this type of exception would be generated. So I have a valid reason for needing this type of info. I was wondering if anyone knew of this type of list, so that I can save come time. Thanks.
 
William Barnes
Ranch Hand
Posts: 1049
2
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, how about this. Anyone have any suggestions besides there:

Integer: string ctor, parseInt, valueOf, decode
Long: string ctor, parseLong, valueOf, decode
Short: string ctor, parseShort, valueOf, decode
Float: string ctor, parseFloat, valueOf
Double: string ctor, parseDouble, valueOf
Byte: string ctor, parseByte, valueOf, decode
BigInteger: some ctors,
BigDecimal: some ctors,
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about the Formatters, like DateFormatter, etc. These through NumberFormatException when a number is passed with characters to a formatter that wants just numbers.

Mark
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!