I am trying to merge multiple docx files to one for a project. But I have done some reasearch and there is no way to find a code that can handle it in Java or Powershell. These are the things that come closest to what I want but it doesn't support multiple files.
package wordv2;
import java.io.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Wordv2 {
public static void main(String[] args) {
FileInputStream instream = null;
FileOutputStream outstream = null;
try {
File infile = new File("C:\\jeux\\test.docx");
File outfile = new File("C:\\jeux\\MyOutputFile.docx");
instream = new FileInputStream(infile);
outstream = new FileOutputStream(outfile);
byte[] buffer = new byte[1024];
int length;
/*copying the contents from input stream to
* output stream using read and write methods
*/
while ((length = instream.read(buffer)) > 0) {
outstream.write(buffer, 0, length);
}
//Closing the input/output file streams
instream.close();
outstream.close();
System.out.println("File copied successfully!!");
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
Do you have any ideas to make it able to handle my request or do you know any other code that can do it?