|
-
Oct 21st, 2002, 08:41 AM
#1
Thread Starter
Banned
Urgent: What's wrong with my code?
Hi.
I'm using a StringTokenizer to read column data, which is seperated by tabs, from a .txt file. And one of the column fields is $18.00. The followings is part of my code.
=====================================
NumberFormat NF = NumberFormat.getInstance();
myStrings = new StringTokenizer(strLine, "\t");
if (myStrings.countTokens()==8) {
ItemNo = new Integer(myStrings.nextToken()).intValue();
System.out.println (ItemNo);
Description = myStrings.nextToken();
System.out.println(Description);
Price = NF.parse(myStrings.nextToken());
System.out(Price);
}
=====================================
The program can show ItemNo and Description on the putput screen when I complie it, but it can't show "Price". Instead, an error message: "Exception in thread "main" java.lang.NumberFormatException: $18.00" comes out.
Would you tell me how to fix it?
Thanks a lot!!!
Jacob
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|