|
-
Nov 13th, 2006, 10:14 AM
#1
Thread Starter
Hyperactive Member
Splitting Data [resolved]
I have the following data(these are just three lines of the file that i am reading in) that I need to split up and put into an array. Its date, worker name with id number, followed by hours worked each day for the entire week.
Code:
11/03/06 John Doe 4335 40-42-40-32-40
11/03/06 Jason Doe 2233 40-2-9
11/03/06 Jane Doe 8831 12-17
There are about 2-15 spaces between Data and Name and about the same between the last number of the id and the hours worked.
I need to put date, name & id, and hours into an array. How do I go about dividing up the data so that i can insert it into an array?
Any help is appreciated.
Last edited by mrstuff68; Nov 14th, 2006 at 09:59 AM.
-
Nov 14th, 2006, 03:52 AM
#2
Re: Splitting Data
Well, it's a simple whitespace-separated format. Every line has 5 fields, separated by any amount of whitespace.
So what you do is, you read in a line, then you use any of several splitting methods Java provides to split it into its parts. Then you parse each part (converting the date to a Date instance, converting the ID to a number, etc.) and store it.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 14th, 2006, 09:58 AM
#3
Thread Starter
Hyperactive Member
Re: Splitting Data
Thanks, i decided to do a split on the spaces.
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
|