日期:2014-05-18  浏览次数:20678 次

如何用java流来向htm文件中插入一字符串
我用jacob将word生成了htm.     我想在这个htm中的 ' <w:WordDocument> '这句之后插入一句 ' <w:View> Print </w:View> '   并有这句是要换行的.    

不知道这个用java流是否能实现,如果能的话具体该怎么做呢.   帮帮忙顶一下也好.有分的.

------解决方案--------------------
使用sevelet
------解决方案--------------------
mark
------解决方案--------------------
BufferedReader reader = new BufferedReader(new FileReader( "C:/src.html "));
PrintWriter writer = new PrintWriter(new FileWriter( "C:/dest.html "));
String line = null;
while((line = reader.readLine()) != null) {
int index = line.indexOf( " <w:WordDocument> ");
if(index > = 0) {
writer.println(line.substring(0, index + " <w:WordDocument> ".length()));
writer.println( " <w:View> Print </w:View> ");
if(index + " <w:WordDocument> ".length() != line.length())
writer.println(line.substring(index + " <w:WordDocument> ".length()));
} else
writer.println(line);
}
reader.close();
writer.close();