I have a data file which is comprised of rows of data, newline separated. I need to read the contents of the file into an array of Strings, and I would like to efficiently create the array at the correct size. Is it most efficient to
Use an ArrayList
(your option #1). Read in your text file line by line with BufferedReader
's readLine()
method. It's simple, efficient and maintainable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With