Results 1 to 4 of 4
  1. #1
    wholegrain is offline Member
    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0

    Question How do you break down a string to store different types of data into an array?

    Using substring()? I already wrote a method to read lines from a txt file and convert them into strings. Do I need to write a specific method in the Person class?

    Here's the input from the txt file:

    1LUONGO ROBERT M 1,69 64,9
    2BUSH GEORGE M 1,47 52,2
    3GOLDBERG JOHN M 1,89 72,3
    4PAULSON MARTIN M 1,73 60,5

    Different types of information are evenly spaced, except the rank, which is attached to the last name.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: How do you break down a string to store different types of data into an array?

    What does the actual text in the text file look like? What happens when you reach person number 100? What happens if someone's name has a suffix such as Jr. or Sr.?

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,419
    Rep Power
    20

    Default Re: How do you break down a string to store different types of data into an array?

    OP asked two more questions without first replying here. I have posted in both those threads:
    When you post a question here, we expect you to reply to responses. Not just post one more and yet another while ignoring Fubarable's response on
    How do you break down a string to store different types of data into an array?
    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    sugarbalboa is offline Member
    Join Date
    Feb 2012
    Posts
    1
    Rep Power
    0

    Default Re: How do you break down a string to store different types of data into an array?

    Something like this should help you:

    public onePerson(String Line)throws Exception
    {
    String[] delene=Line.split(" ");
    Firstname=delene[0].trim();
    Lastname=delene[1].trim();
    and so on...
    }

Similar Threads

  1. Replies: 3
    Last Post: 11-01-2011, 07:58 PM
  2. how to store data in array
    By aconti in forum New To Java
    Replies: 7
    Last Post: 06-18-2011, 06:24 PM
  3. HOw to Store Data in An Array
    By deshmukh.niraj04 in forum New To Java
    Replies: 4
    Last Post: 04-06-2011, 04:00 AM
  4. Comparing two data types in order to store in array
    By gwithey in forum New To Java
    Replies: 3
    Last Post: 05-01-2009, 10:27 AM
  5. Array of different data types?
    By venkatteshb in forum New To Java
    Replies: 1
    Last Post: 08-27-2008, 05:42 PM

Posting Permissions

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