Ok, so I'm working on a class that I can use to save and load text files as String[] arrays (each line in the file is another element in the array).
I know how to do all the saving and loading just fine, but I'm running into a little trouble with creating the arrays. Specifically, I don't know to figure out how many lines are in the file before I start reading stuff from it, so I don't know how large to make the array.
Right now, the best thing I can think of is making the array exceptionally large and including a count of how many things I read, then making a second array afterwards with the correct dimensions and returning that. There's gotta be a more elegant way, though. Is there any way to count the number of lines in a file or make an existing array longer?
I know how to do all the saving and loading just fine, but I'm running into a little trouble with creating the arrays. Specifically, I don't know to figure out how many lines are in the file before I start reading stuff from it, so I don't know how large to make the array.
Right now, the best thing I can think of is making the array exceptionally large and including a count of how many things I read, then making a second array afterwards with the correct dimensions and returning that. There's gotta be a more elegant way, though. Is there any way to count the number of lines in a file or make an existing array longer?
