Skip to content
Advertisement

How to save Each index of Array List in text file as new line in java?

I am trying to save each index of list as new line in text file in format below in java and read same as two separate Array List for later . I have done the saving part now i want to read it back into two separate lists

Save Formate

Class SaveLists

JavaScript

Class Main :

JavaScript

Advertisement

Answer

As both the save operations are on the same thread the lines would be written to the file in a synchronous manner. So after reading all the lines from the file we can split the lines based on the size of the input lists i.e. the first set of values would have been inserted by the ‘First’ list.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement