Results 1 to 5 of 5
  1. #1
    rsoler is offline Member
    Join Date
    Mar 2009
    Posts
    1
    Rep Power
    0

    Default 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

  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    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.

  3. #3
    arseny is offline Member
    Join Date
    Mar 2009
    Posts
    25
    Rep Power
    0

    Default

    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

  4. #4
    anjali is offline Member
    Join Date
    Mar 2009
    Posts
    9
    Rep Power
    0

    Default

    hello,
    u want to seperate the string or what?

  5. #5
    Lynx09 is offline Member
    Join Date
    Mar 2009
    Posts
    8
    Rep Power
    0

    Default

    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

  1. Xml Parsing
    By Nomad in forum XML
    Replies: 12
    Last Post: 02-22-2009, 12:19 PM
  2. xml parsing help
    By tankhardrive in forum XML
    Replies: 2
    Last Post: 02-12-2009, 12:45 AM
  3. printing two smallest numbers from a series of numbers
    By trofyscarz in forum New To Java
    Replies: 2
    Last Post: 10-15-2008, 12:46 AM
  4. Parsing URL
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-26-2007, 11:16 AM
  5. validating a string for numbers and letters?
    By lockmac in forum New To Java
    Replies: 1
    Last Post: 08-09-2007, 10:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •