Answer:
The code to this question can be given as:
Code:
//creating a file class object.
File f1 = new File();
f1.File(file1); //call parameterized constructor
.
File f2 = new File();
f2.File(file2); //call parameterized constructor
.
//creating Scanner class object for user input and pass parameter
Scanner ob1 = new Scanner(f1);
Scanner ob2 = new Scanner(f2);
//create String variable File3 that holds the value of file1 and file2
String File3 = file1 + "-" + file2;
//create File class object and pass parameter File3.
File files = new File(File3);
//creating PrintWriter class object.
PrintWriter ob = new PrintWriter();
ob.
PrintWriter(file3); //call parameterized constructor
.
while(ob1.hasNextLine()) //loop
{
//print value.
System.out.println(ob1.nextLine());
System.out.println(ob2.nextLine());
}
output.close();
output.close();
Explanation:
In the above java code firstly we create the File class object.Then we call the parameterized constructor of this class. Then we create the scanner class object. In the input time, we pass the parameter to scanner class object and we declare the String variable that is File3. In this variable, we add both file1 and file2 value with concatenating "-". Then we create the PrintWriter class object and call their constructor. At the last, we declare the loop that prints all the values.