PDA

Click to See Complete Forum and Search --> : Splitting Data [resolved]


mrstuff68
Nov 13th, 2006, 10:14 AM
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.

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.

CornedBee
Nov 14th, 2006, 03:52 AM
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.

mrstuff68
Nov 14th, 2006, 09:58 AM
Thanks, i decided to do a split on the spaces.