我有一个WORD模板,里面有占位符${name},我要把${name}用数据库中读出来的值替换,然后生成新的WORD文档,
可是新生成的WORD文档一打开就提示文件损坏。代码如下:
FileInputStream in = new FileInputStream("C:\\blank.doc"); 
HWPFDocument doc = new HWPFDocument(in); 
Range range = doc.getRange(); 
Range currentRange = range; 
currentRange.replaceText("${name}", "aaa");
FileOutputStream out = new FileOutputStream("C:\\a.doc"); 
doc.write(out); 
out.flush(); 
out.close();有什么不对的吗?跪求高人指点。。