There are two text files, whose names are given by two String variables, file1 and file2. These text files have the same number of lines. Write a sequence of statements that creates a new file whose name consists concatenating the names of the two text files (with a "-" in the middle) and whose contents of merging the lines of the two files. Thus, in the new file, the first line is the first line from the first file, the second line is the first line from the second file. The third line in the new file is the second line in the first file and the fourth line is the second line from the second file, and so on. When finished, make sure that the data written to the new file has been flushed from its buffer and that any system resources used during the course of running your code have been released.

Respuesta :

The program is an illustration of file manipulation

What is file manipulation?

File manipulation involves reading from a file, appending content to a file and writing out from a file

The main program?

The program written in Java, where comments are used to explain each action is as follows:

//This creates an object of file 1

 File file1 = new File(file1);

 //This creates an object of file 2

 File file2 = new File(file2);

    //This reads the content of file 1

 Scanner input1 = new Scanner(file1);

 //This reads the content of file 2

 Scanner input2 = new Scanner(file2);

 //This gets the name of the new file

 String sFile3 = file1 + "-" + file2;

 //This creates an object of file 3

 File file3 = new File(sFile3);

 //This creates an object of the output file

 PrintWriter printOut = new PrintWriter(file3);

 //The following loop is repeated until the end of file 1

 while(input1.hasNextLine()){

     //These print each line of files 1 and 2 to file 3

     printOut.println(input1.nextLine());

     printOut.println(input2.nextLine());

 }

 //This closes file 1

 printOut.close();

 //This closes file 2

 printOut.close();

Read more about file manipulation at:

https://brainly.com/question/16397886