Building an array from .txt file.
I am trying to fill an array with words from a text file. Each line in the file has exactly one word.
I would like to sequentially fill each position in the array with one line/word.
I planned on using a counter controlled loop to fill each position in the array.
The only problem is reading a single line at [count] from the text file.
Any help would be appreciated.
Re: Building an array from .txt file.
Why would you want to read a line at a given position? Simply read the file sequentially and place them line read into the array sequentially. You need to counter to access the array not the file.
Re: Building an array from .txt file.
If you use a FileReader and put that into a BufferedReader, you could use the BufferedReader's readLine method to read only one line of the file at a time.
Re: Building an array from .txt file.