00:01
Hello students, here is a java code that reads the integer from the file, sorts them using an insertion sort algorithm and then writes the sorted integer to another file.
00:12
So here, an array list of integer number is equal to the new array list.
00:18
As the array list named as the number is created to store the integer read from the file.
00:25
As then the try buffered reader that reader is equal to the new buffer reader.
00:32
Here the buffer reader is used to read the file, read the data from a file named as the data .txt as the data .txt from that the code is enclosed in a try with a resource block to ensure that the reader is properly closed after reading.
00:50
That the string line is equal to null, these line is tries a string variable as line to null, it will be used to read each line of the text from the file.
01:02
Whereas into a while loop, this loop reads the each line from the file using the read line method until the end of the file is reached.
01:12
As int of num, each line reads from the file is converted into an integer assuming that the file contains the valid integer value.
01:22
As the integer num is added to the numbers list, where this sorts as the sorts that perform insertion sort, here method forms this sort class is used to sort the integer in the number list using the insertion sort algorithm, whereby using the for loop, this loop iterates through the sorted integer in the numbers list and prints them to the console...