专题文章
时长:00:00更新时间:2024-12-11 20:16:39
首先,打开一个现有的Word文件,通过FileInputStream读取文件,并使用POIFSFileSystem解析文件内容,再创建一个HWPFDocument对象。接着,通过OutputStream将修改后的文档内容写入到新的目标文件中。具体代码如下:FileInputStream fileInputStream = new FileInputStream(soureFile)。POIFSFileSystem pfs = new POIFSFileSystem(fileInputStream)。HWPFDocument hwpf = new HWPFDocument(pfs)。OutputStream output = new FileOutputStream(targetFile)。
查看详情