aspose file tools*
The moose likes Java in General and the fly likes convert string to number Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "convert string to number" Watch "convert string to number" New topic
Author

convert string to number

phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
I have string like

/$VVCk*KKKKL4208.56DDDD
EUR 6666.37 GGGG RRRRR LLLL /KKKK

I need to retrieve only 6666.37.

Can anyone help me in this case?

thanks


fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11477
    
  16

What have you tried?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
I have tried only string.substring(int start, int end).

do we have any other alternative also?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11477
    
  16

you could try regular expressions, too. part of the difficulty of helping you is that your data layout isn't clear.

What starts a record? it is unclear if what you posted is one string that you just formatted on two lines here, if it comes in as as single string with a newline character in it, or if you have two separate strings. Further, are you only doing this once, or is there a file with dozens or hundreds of strings you need to parse?

if you can give us some more details, people can guide you better.

Finally, what happened when you used substring? why didn't it work? What did it give you, and what were you expecting?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: convert string to number