Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NumberFormatException using line.substring  RSS feed

 
Tim Hollis
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to check if a particular point in a sting "line" has any value in it or not. I know that the string will be composed of numbers, so
I have tried using :

I know that this is an awkward way of doing this, and it doesn't work! If the string is empty by the time I get to this point, I get a NumberformatException error.
Can anyone suggest a way I can check if a substing is not null? This HAS GOT to be simple!?!
 
Gyula Klinszky
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try checking the length of said string !
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should break each function call into its own line. This would help simplify things drastically.
HTH
Layne
 
William Barnes
Ranch Hand
Posts: 1049
2
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya, what Layne said.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!