0
我想将多个docx文件合并为一个项目。但是我做了一些研究,并且没有办法找到可以在Java或Powershell中处理它的代码。这些是最接近我想要的东西,但它不支持多个文件。Java/Powershell:将大量docx文档合并为一个,并保留所有文档的格式
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();
}
}
}
你有什么想法,使其能够处理我的请求,或者你知道的任何其他代码,能做到吗?
对不起,请问你有没有exempel?我是一个非常漂亮的新程序员,我尽我最大的努力,但并不是总能找到其他人试图解释的东西,并且确实格式不对吗? – Elaxe
@Elaxe https://www.tutorialspoint.com/apache_poi_word/apache_poi_word_quick_guide.htm – daddycool
@Elaxe我也建议看看http://stackoverflow.com/questions/25130419/how-to-copy-some-content-in-一DOCX到使用-POI-而不-失去感到另一个-DOCX- – daddycool