81,122
社区成员




public String Bindht(String asoption, String content) {
String rpath = "";
//生成html文件的路径
String bindFile="cia/";
String demoFile = "WebRoot/aademo.html";
InputStreamReader read = null;
BufferedReader br = null;
OutputStreamWriter writer = null;
BufferedWriter bw = null;
try {
File inputPath = new File(demoFile);
read = new InputStreamReader(new FileInputStream(inputPath),
"UTF-8");
br = new BufferedReader(read);
Calendar calendar = Calendar.getInstance();
String bindName = String.valueOf(calendar.getTimeInMillis())
+ ".html";
bindFile = "WebRoot/" + bindFile + bindName;
File outputPath = new File(bindFile);
writer = new OutputStreamWriter(new FileOutputStream(outputPath),
"UTF-8");
bw = new BufferedWriter(writer);
String s = br.readLine();
while (s != null) {
if (s.trim().equals("#######################################")) {
String news = s.replaceAll(
"#######################################", content);
bw.write(news);
bw.newLine();
s = br.readLine();
} else {
bw.write(s);
bw.newLine();
s = br.readLine();
}
}
StringBuffer tempPath=new StringBuffer(bindFile);
rpath=tempPath.delete(0,8).toString();
System.out.println(rpath);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
br.close();
bw.close();
read.close();
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return rpath;
}