请问,如何用java写过doc版本的文档合并啊?

请问有没有,用java写过doc版本的文档合并啊,求问。

HWPFDocument doch = new HWPFDocument(in);
Range range = doch.getRange();


import java.io.*;
import org.apache.poi.xwpf.usermodel.*;

public class MergeWordDocs {
    public static void main(String[] args) throws Exception {
        // Open the first document
        XWPFDocument doc1 = new XWPFDocument(new FileInputStream("doc1.docx"));

        // Open the second document
        XWPFDocument doc2 = new XWPFDocument(new FileInputStream("doc2.docx"));

        // Create a new document
        XWPFDocument mergedDoc = new XWPFDocument();

        // Copy the contents of the first document to the new document
        for (XWPFParagraph para : doc1.getParagraphs()) {
            mergedDoc.createParagraph().createRun().setText(para.getText());
        }

        // Copy the contents of the second document to the new document
        for (XWPFParagraph para : doc2.getParagraphs()) {
            mergedDoc.createParagraph().createRun().setText(para.getText());
        }

        // Save the merged document
        FileOutputStream out = new FileOutputStream("merged.docx");
        mergedDoc.write(out);
        out.close();

        System.out.println("Documents merged successfully.");
    }
}