Results 1 to 5 of 5
Thread: parsing numbers in a string
- 03-24-2009, 11:38 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 1
- Rep Power
- 0
parsing numbers in a string
I got an string with values of lat long and i want to get the content of each first the desccription and then the values
the string
Autopista Caracas-ValenciaCaraboboCalles, carreteras, caminos, o ferrocarril10.2166667-67.3333333Autopista Valencia Puerto CabelloCaraboboCalles, carreteras, caminos, o ferrocarril10.3272222-68.0961111
i want o get
Autopista Caracas-ValenciaCaraboboCalles, carreteras, caminos, o ferrocarril@10.2166667 -67.3333333
Autopista Valencia Puerto CabelloCaraboboCalles, carreteras, caminos, o ferrocarril@10.3272222 -68.0961111
etc
the @ and the blank space added to parse later
thanks in advance
r.soler
- 03-24-2009, 02:53 PM #2
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
So, it looks like the delimiter is two floating point numbers? Is there a newline between them?
If there is a newline between them you can create an appropriate type of Reader, and use the readLine method. If not, you can use regular expressions to split the text.
- 03-25-2009, 10:24 PM #3
Member
- Join Date
- Mar 2009
- Posts
- 25
- Rep Power
- 0
There are two classes java.text.DecimalFormat and java.text.NumberFormat which can help to You (they both have a parse - method). java help describes how it can be used
- 03-30-2009, 08:14 AM #4
Member
- Join Date
- Mar 2009
- Posts
- 9
- Rep Power
- 0
hello,
u want to seperate the string or what?
- 03-31-2009, 06:05 AM #5
Member
- Join Date
- Mar 2009
- Posts
- 8
- Rep Power
- 0
I don't really get what you want so I am going to describe how to turn a string in to a number and how to turn a number into a string. First number into a string. You can use Wrapper classes, double dNum = 4.5; Double obj = new Double(dNum); obj.toString(); Will make the number in to a string. This may also work for long and short though I never tried it. Next is parsing a string back into a number. Lets say String strValue = "33"; int num; Intgeter.parsInt(strValue); ... Or You can do this if it is a double, String strValue = 33.0; double dNum; Double.parseDouble(strValue);...
Similar Threads
-
Xml Parsing
By Nomad in forum XMLReplies: 12Last Post: 02-22-2009, 11:19 AM -
xml parsing help
By tankhardrive in forum XMLReplies: 2Last Post: 02-11-2009, 11:45 PM -
printing two smallest numbers from a series of numbers
By trofyscarz in forum New To JavaReplies: 2Last Post: 10-14-2008, 11:46 PM -
Parsing URL
By Java Tip in forum Java TipReplies: 0Last Post: 12-26-2007, 10:16 AM -
validating a string for numbers and letters?
By lockmac in forum New To JavaReplies: 1Last Post: 08-09-2007, 09:17 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks