There are two parts to this question:
I am using java, I have a text file (names.txt) filled with information of the following format:
Pierre
Marco
Leon
Cecil
...
(it goes on for several hundreds of more names)
How can I scan it into an ArrayList of strings? so that each line is a string in the ArrayList (in order), for example:
list names = [Pierre, Marco, Leon, Cecil, ...]
Also, my program generates names and stores them in an ArrayList, how would I go about creating a new text file (in the same directory) and having my program write the generated names from the ArrayList onto a new text file? (essentially the reverse process)
so for example, if I have an ArrayList:
list newNames = [Caesar, Bastion, Richter, Juste]
I want to write it to a new text file (newNames.txt) so that:
Caesar
Bastion
Richter
Juste
like before, I want to preserve the order of the names so that the first in the ArrayList is at the top of the text file, and the last in the ArrayList is at the bottom of the text file