62,614
社区成员
发帖
与我相关
我的任务
分享
FileInputStream in = new FileInputStream(demoFile);
HWPFDocument hdt = new HWPFDocument(in);
// 读取word文本内容
Range range = hdt.getRange();
// 替换文本内容
for(Map.Entry<String, String> entry : map.entrySet())
{
range.replaceText(entry.getKey(), entry.getValue());
}
ByteArrayOutputStream ostream = new ByteArrayOutputStream();
FileOutputStream out = new FileOutputStream(newFile, true);
hdt.write(ostream);
// 输出字节流
out.write(ostream.toByteArray());
out.close();
ostream.close();