Dear All
My program needs to read contents of a file into an array , for example my
file contains :
4 3 4
2 3 1 5
1 2
2 4 5 6 7 7
I deeply appreciate your help with this question :
How can I set up an array , specially that my column sizes are different as
you can see , to fill it with contents of a file?
Thank You
Denis
bugbear - 19 Dec 2006 16:49 GMT
> Dear All
>
[quoted text clipped - 10 lines]
> How can I set up an array , specially that my column sizes are different as
> you can see , to fill it with contents of a file?
You either need 2 passes, or a more dynamic data structure
than an array.
The "obvious" answer is an ArrayList or ArrayLists.
BugBear
Daniel Pitts - 19 Dec 2006 23:14 GMT
> Dear All
>
[quoted text clipped - 13 lines]
> Thank You
> Denis
You would be better off if you also told us what you expected the array
to look like.
{4,3,4}
{2,3,1,5}
{1, 2}
{2, 4, 5, 6, 7, 7}
If thats the case, then you need to read the file one line at a time,
and then build the array based on the number of tokens. Or use an
ArrayList (which automatically resizes for you).
Hope this helps.
- Daniel.