Meaningless Drivel is fun!
The moose likes Java in General and the fly likes NumberFormatException using line.substring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "NumberFormatException using line.substring" Watch "NumberFormatException using line.substring" New topic

NumberFormatException using line.substring

Tim Hollis

Joined: Mar 18, 2003
Posts: 1
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

Joined: Jan 20, 2003
Posts: 27
Try checking the length of said string !
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
You should break each function call into its own line. This would help simplify things drastically.

Java API Documentation
The Java Tutorial
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

Ya, what Layne said.

Please ignore post, I have no idea what I am talking about.
I agree. Here's the link:
subject: NumberFormatException using line.substring
It's not a secret anymore!