81,092
社区成员
发帖
与我相关
我的任务
分享
/**
* WordHandle.java
* 全局替换
* @param oldText 要替换的文本
* @param newText 替换为文本
*/
public boolean replaceAll(String oldText, String newText) throws Exception {
// 移动到文件开头
moveStart();
// 循环查找并替换
while(search(oldText)!=0) {
replace(newText);
Dispatch.call(selection, "MoveRight");
}
return true;
}
WordHandle wordHandle = new WordHandle();
wordHandle.replaceAll("${keyword}", keyword); //主题词
wordHandle.replaceAll("${unitname_cc}", unitname_cc); //抄送
//发布时间
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
wordHandle.replaceAll("${pubdate}", format.format(pubdate));