Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

find out Integers in String

807569Sep 6 2006 — edited Sep 6 2006
Hi all:
I am stuck with a simple problem here. I have a file where there are 2 data types String(Item_Name) and int(Item_Code). Something like this:
 ----------------------------------------------------
  Item_Code            |          Item_Name  |
----------------------------------------------------
     34                                  Pens
       7                                   Ice Cream
---------------------------------------------------- 
Now, I can catch the error if users input character in Item_code like '34ab' with NumberFormatException but how to catch if they put digits in Item_Name like 'Pen345s' ?
Should I first use string tokenizer to divide the strings and then check by individual characters? How to know if its a digit?

thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 4 2006
Added on Sep 6 2006
21 comments
214 views