I am working on a big project where I have more than 1 million lines of data. Data is divided into various files containing 20,000 lines each. Now the data from each file is read line by line and some variable x is concatenated to each line. I am storing these concatenated string to an array list. Then this array list is saved to output files line by line.
This is taking 3-4 minutes on each file. Is there anyway to write the entire ArrayList
to a file in one go, so that it won't take that much time. Or is there any faster way to do this?
Here is some sample code:
List<String> outputData = new ArrayList<String>();
//Output arraylist containing concatenated data
writeLines(File outputFile,outputData); //The data is written to file
What would be the fastest way to achieve this task?