Computer Science Canada Need help with transfering names from a txt file to array |
Author: | supahsain08 [ Thu May 29, 2008 6:01 pm ] | ||||
Post subject: | Need help with transfering names from a txt file to array | ||||
Hello, my program is suppose to read data from a txt file txt file has like 20 names (each name on a different line)
I am almost done, but i am experiencing problems reading names from a txt file here's my code so far
|
Author: | r691175002 [ Thu May 29, 2008 7:00 pm ] | ||||
Post subject: | Re: Need help with transfering names from a txt file to array | ||||
Well to start I would suggest switching to a Scanner just to reduce the linecount:
I believe you are asking how to transfer the names into an array. IMO the easiest way would be to use an ArrayList:
I really don't see any reason not to use the built in classes to do this. Since it seems that you are learning sorting algorithms, you probbably want a real array so you can use ArrayList.toArray() and have the entire thing read into an array in 5 lines. |